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.
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With