I have two old domains http://example1.com (English) and http://example2.com (French) and would like them to redirect to my new domain such as:
Also I want to make sure the permalinks remain the same after redirecting as well.
E.g. http://example1.com/test.html => http://newdomain.com/en/test.html
My Code:
The below code fails to maintain the permalinks, also I am not sure how to add the french domain in the check.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example1.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example1.com$
RewriteRule (.*)$ http://www.newdomain.com/en/$1 [R=301,L]
</IfModule>
2
Answers
The following should work:
As for keeping the permalinks, I don’t think you can do it here, you’ll have to do it in the new domain’s
.htaccess
.What do you use for translation ? Does it accept query parameters or is able to parse the uri by itself ?
Have it like this:
Make sure to keep these rules as your top rules before other rules and you test in a new browser to avoid old browser cache.