French and English domain (problem with '^/*' ?)

New to mod_rewrite? This is a good place to start.

French and English domain (problem with '^/*' ?)

Postby rthakrar » Mon Sep 21, 2009 1:24 am

Hi,

I've been playing with this for a couple of days using research and trial and error!

- Everything is hosted on frenchdomain.com
- The English version of the site uses /en_index.php?p=page
- The French version uses /index.php?p=page

This is what I guess should be the .htaccess (i.e. regardless of www., and regardless of whether default index file specified or just blank, redirect to en_index on the English domain)...

Code: Select all
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?englishdomain\.com [NC]
RewriteCond %{HTTP_HOST} !^(www\.)?frenchdomain\.com [NC]
RewriteRule ^/$ en_index.php [L,r=301]
RewriteRule ^index.php$ en_index.php [L,r=301]


The current result of the above is:
- frenchdomain.com works in French (correct)
- englishdomain.com works in French (incorrect)
- englishdomain.com/index.php works in English (correct)

I guess it's my third line of code...?

Thanks in advance!

R
rthakrar
 
Posts: 2
Joined: Mon Sep 21, 2009 12:52 am

Postby richardk » Mon Sep 21, 2009 10:30 am

RewriteConds only apply to one RewriteRule.

Code: Select all
RewriteCond %{HTTP_HOST} ^(www\.)?englishdomain\.com [NC]
RewriteCond %{HTTP_HOST} !^(www\.)?frenchdomain\.com [NC]

You only need the first condition. If it is englishdomain it can't be frenchdomain.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?englishdomain\.com$ [NC]
RewriteRule ^(index\.php)?$ /en_index.php [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby rthakrar » Mon Sep 21, 2009 11:15 am

Grr, so simple when you know how! I should have really spotted the missing backslash in 'index.php'...

Thanks so much for your help, richardk - really appreciated and have noted where I went wrong!

Warm regards,

R
rthakrar
 
Posts: 2
Joined: Mon Sep 21, 2009 12:52 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 26 guests

cron