Forum

Thread tagged as: Problem, Hosting, Runway

Runway wildcard subdomain rewrites

Hello, I have a website which wishes to use wildcard subdomains and I can't get them to work 100% with htaccess. A few people have helped and we are very close but still an issue, wondering if anyone can assist?

https://core24stage.com.au/ Home - works!

https://core24stage.com.au/find-a-club Page - works!

https://sub.core24stage.com.au/ Subdomain - shows 404 :( (should show https://core24stage.com.au/sd/sub)

https://sub.core24stage.com.au/sub-test-1 Subdomain child page - WORKS! (shows https://core24stage.com.au/sd/sub/sub-test-1)

Here is the htaccess:

Options -Indexes +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^(.*)\.core24stage.com.au$ [NC]
RewriteRule ^(.*)$ https://core24stage.com.au/sd/%1/$1 [P,NC,QSA]

RewriteCond %{REQUEST_URI} !^/core_admin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /core_admin/core/runway/start.php [L]

It seems like it should work, see here: https://htaccess.mwl.be?share=2b42aca7-9471-50f7-bec1-ae2c5935bf8f

Brad Hardinge

Brad Hardinge 0 points

  • 3 years ago

Not sure, but maybe you should consider not using a "naked" domain for your main site anyway: https://www.yes-www.org/why-use-www/
Especially when using subdomains too.

Thanks Nils. Happy to use www. I just tried a few things, but more issues. This stuff is doing my head in! Why is it so hard to find an expert with mod_rewite/mod_proxy!?!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you trying to redirect, or just internally rewrite?

Internally rewrite. After Nils suggestion to force www, these are the 4 types of link I need to get working:

  1. Home: https://www.core24stage.com.au/

  2. Page: https://www.core24stage.com.au/find-a-club

  3. Subdomain: https://sub.core24stage.com.au/ (should show the content from https://www.core24stage.com.au/sd/sub/ using mod_proxy)

  4. Subdomain page: https://sub.core24stage.com.au/sub-test-1 (should show the content from https://www.core24stage.com.au/sd/sub/sub-test-1 using mod_proxy)

I think I got it working!

I added a REQUEST_URI variable to the 404 page to debug and realised the subdomain page was looking for /sd/sub/index.html.var which was causing the issue.

A quick google and I added DirectoryIndex "" to the top of the htaccess file and all the links seem to be working :)