Reputation: 447
The website in question had a sub domain for the eCommerce platform, but now we've added the eCommerce functionality to the main site, so now we want to entire shop sub domain to redirect to the home page. Currently I'm using the following code in the .htaccess file:
RewriteCond %{HTTP_HOST} ^shop.domain.co.za$ [NC]
RewriteRule ^(.*)$ http://www.domain.co.za%{REQUEST_URI} [R=301,NC,L,QSA]
This redirects any URL on the sub domain to that same URL on the main site, so shop.domain.co.za/product will redirect to www.domain.co.za/product, but we want it to redirect to home page, since the URL structure has completely changed.
So in other words, we want any URL on shop.domain.co.za to rediect to the home page, www.domain.co.za, how can this be done?
Any help would be greatly appreciated.
Thanks
Willem
Upvotes: 2
Views: 1342
Reputation: 785256
You can replace your rule with this rule:
RewriteCond %{HTTP_HOST} =shop.domain.co.za
RewriteRule ^ http://www.domain.co.za/? [R=301,L]
Using %{REQUEST_URI}
will cause original URI to be copied in target.
Trailing ?
in target will strip off any pre-existing query string.
Upvotes: 3