Reputation: 15
I have a strange problem with .htaccess and google. I have multiple-different root domain with 301 redirection to main domain, and that's ok, but i have also multiple languages like so .com/sl, .com/it, .com/en, and .net/sl, .net/it, .net/en the problem is when you click on the link from google is wwww.old-domain.com/sl and that's right, but when you click on it the url become like this www.new-domain.comsl so the slash is missing and of course the page does not work.
So is there a fix in htaccess? my htacces redirects are:
RewriteCond %{HTTP_HOST} ^old-domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.com/$ [OR]
RewriteCond %{HTTP_HOST} ^old-domain.net/$ [OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.net$
RewriteRule ^(.*)$ "http\:\/\/www\.new-domain\.com$1" [R=301,L]
So I have to fix this www.old-domain.comsl to www.new-domain.com/sl
Thanks to all.
Upvotes: 1
Views: 278
Reputation: 72961
You should not need the trailing /
in your RewriteCond
. Furthermore, you are escaping incorrectly (you need to do it in the opposite places).
Clean it up with the following and see if it solves your issue.
RewriteCond %{HTTP_HOST} ^old-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^old-domain\.net$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old-domain\.net$
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]
Upvotes: 2
Reputation: 802
I think you forgot a slash.. Try this?
RewriteCond %{HTTP_HOST} ^old-domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.com/$ [OR]
RewriteCond %{HTTP_HOST} ^old-domain.net/$ [OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.net$
RewriteRule ^(.*)$ "http\:\/\/www\.new-domain\.com\/$1" [R=301,L]
Upvotes: 3