I’m having some trouble setting up a htaccess file. Currently I have 15 domains serving their own website. Now moving this to a single website and domain, I want to serve a htaccess with 301 rules for the old urls. The destination url depends on the domainname of the old url..
E.g.
http://www.previouswebsiteinspanish.com/contacto should be permanently rewritten to http://www.newcentralwebsite.eu/es/contact
I understand that I have to use the RewriteCond but I’m not familiar enough with it to get it working.
RewriteCond %{HTTP_REFERER} !^http://(www\.)?previouswebsiteinspanish/.*$ [NC]
RewriteRule ^([^/.]+)/contacto$ /$1/contact [R=301,L]
Thanks in advance!
You current condition is that the rule will be executed under the condition that the referring page is not on the old domain. That’s most likely not what you want to do. 🙂
You want to check the %{HTTP_HOST} parameter, which contains only the hostname part of the currently requested URL.
Assuming you want to redirect everything on the old domain to the
essubfolder, this rule will do it.Then you’ll have to add similar rules for each old domain.