0

I have a website, www.thesite.com and an alias www.lesite.com

i need a htaccess redirection: I would like that, when I go to www.thesite.com/fr, it redirects me to www.lesite.com/fr

Likewise, when I go to www.lesite.com/en, I would like it to redirect me to www.thesite.com/en

I have tried different methods but i only succeed to create infinite loops !----

Options +FollowSymlinks
RewriteRule ^fr$ http://dev.mariage.ch/fr/ [L] 
RewriteRule ^de$ http://dev.hortzeit.ch/de/ [L] 

OR

RewriteCond %{HTTP_HOST} !^dev\.hortzeit\.ch\/de\/
RewriteRule (.*) http://dev.hortzeit.ch/de$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^dev\.mariage\.ch\/fr\/
RewriteRule (.*) http://dev.mariage.ch/fr$1 [R=301,L]
user2869049
  • 129
  • 1
  • 9
  • already answered here :http://stackoverflow.com/questions/10232722/htaccess-rewrite-based-on-hostname-or-domain-name#10241757 and here : http://stackoverflow.com/questions/6972413/htaccess-rewriterule-two-domains-using-same-server-and-directory – efx Sep 29 '16 at 14:02

1 Answers1

1

You can't use path as part of RewriteCond for HTTP_HOST instead of dev.hortzeit.ch/de you must use just host part dev.hortzeit.ch

RewriteEngine On
RewriteCond %{HTTP_HOST} !^dev\.hortzeit\.ch  [NC]
RewriteRule ^de(/?.*)$ http://dev.hortzeit.ch/de$1 [R=301,NC,L]

RewriteCond %{HTTP_HOST} !^dev\.mariage\.ch  [NC]
RewriteRule ^fr(/?.*)$ http://dev.mariage.ch/fr$1 [R=301,NC,L]
ban17
  • 634
  • 8
  • 12