Reputation: 8559
Under the /public_html/ folder, on domain.com, there's a folder named shops. Within that folder, there are multiple sub-folders, each with its own index file, css, js etc. For example, there could be one named flowerstore.
I need to have URLs such as shop.domain.com/flowerstore point to /public_html/shops/flowerstore, using the .htaccess.
My current rewrite directives don't seem to work, so I could really use your help.
RewriteCond %{HTTP_HOST} ^shop\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/shops/
RewriteRule (.*) /shops/$1
If it makes any difference, my site is hosted with GoDaddy, but we're using AWS' DNS. Pretty sure it won't make any difference, but rather it's an htaccess quirk.
Upvotes: 9
Views: 11262
Reputation: 13971
Set rewrite engine on and add the below code in .htacess
that will redirect you to sub folder
RewriteEngine on
RewriteCond %{HTTP_HOST} ^shop.domain.com
RewriteRule ^(.*)$ http://domain.com/shops/$1 [L,NC,QSA]
Upvotes: 0
Reputation: 4469
You can achieve this without configuring your .htaccess file. Did you create your shop.domain.com using the Subdomains app? If not, you can then follow these steps:
If you created the subdomain using the Subdomains app, you can simply modify its document root also in that area and set it to "/public_html/shops".
Upvotes: 1
Reputation: 622
Your rules work fine for me. I have tested them on my server.
domain.com -> domain.com/
shop.domain.com -> shop.domain.com/shops/
shop.domain.com/flowershop -> shop.domain.com/shops/flowershop/
RewriteEngine On
RewriteCond %{HTTP_HOST} ^shop\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/shops/
RewriteRule (.*) /shops/$1
I'm not sure how it works on GoDaddy, but you may just need to turn the rewrite engine on as I have in the above.
Upvotes: 8