Reputation: 137
If my website is www.site.com, and there's a shop at www.site.com/shop, how do I make it so that going to shop.site.com, if it doesn't have anything after / (for example shop.site.com/someItem wouldn't redirect) would redirect to www.site.com/shop?
Right now going to shop.site.com/someShopItem redirect correctly to www.site.com/someShopItem, and I need it to stay this way, only change the shop.site.com -> www.site.com/shop
Thank You
Upvotes: 1
Views: 1693
Reputation: 3994
Since we have: RewriteRule Pattern Substitution [OptionalFlags]
from the documentation.
I'm really not a pro for those rules but I guess something like that should be enough ?
RewriteEngine On
RewriteRule ^shop.example.com/?$ http://www.example.com/shop
Which means: replace shop.site.com by www.site.com/shop.
Additionnaly you can test your htaccess with a checker (eg: http://htaccess.madewithlove.be/)
Upvotes: 0
Reputation: 785611
You can use this rule in root .htaccess of shop.site.com
:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^shop\.domain\.com$ [NC]
RewriteRule ^/?$ http://www.domain.com/shop/ [L,NC,R=302]
Upvotes: 3