PlantTheIdea
PlantTheIdea

Reputation: 16369

.htaccess virtual subdomain contains root folder

Alright, so I have done endless Googling, searching through the "Questions that may already have your answer" of StackOverflow ... I cannot seem to find an answer for this. I would greatly appreciate any help my fair community could provide.

I purchased a wildcard SSL for my design site planttheidea.com. I set up a variety of subdomains, both for "psuedo-CDN" purposes (css, js, etc), but also for development and admin stuff. Because I have shared hosting can't cannot modify httpd.conf, the only way I could get multiple subdomains working with an SSL cert for one IP is this rule:

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^dev\.planttheidea\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/dev/ 
RewriteRule ^(.*) /dev/$1

This works incredibly well, and as long as you create it for each subdomain you're golden. There is one major flaw, however: if you do not add a closing /, it re-adds the subfolder into the URL. Example:

Redirects appropriately, the real structure of planttheidea.com/dev/ gets rewritten to dev.planttheidea.com/.

Redirects with the subfolder re-added ... dev.planttheidea.com/dev/planttheidea. The only difference is that finishing / to denote the folder closure.

I know that this is a ridiculously small problem, but I must believe there is some ubergenius out there that wrap up this last little thing that is driving me nuts.

Upvotes: 1

Views: 121

Answers (1)

anubhava
anubhava

Reputation: 786061

Can you try this rule:

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^dev\.planttheidea\.com$ [NC]
RewriteRule !^dev/ /dev%{REQUEST_URI} [L,NC]

Upvotes: 1

Related Questions