Forum Moderators: phranque

Message Too Old, No Replies

htaccess / Drupal / Multilanguage

HTaccess problem with multiple domains

         

Yoerivdm

7:19 pm on Jul 26, 2009 (gmt 0)

10+ Year Member



Hi, I have a drupal installation for a customer on the domain www.exmple.nl. The .NL domain points to the root of hosting. Besides the .NL we also have a domain alias, example.co.uk which also points to the root.

I want to use htaccess to point the .CO.UK domain to the /EN subfolder.

Following rewrite rules are added by drupal:
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

I already added the following rule, resulting in a loop :-S
RewriteCond %{HTTP_HOST} example.co.uk
RewriteCond %{REQUEST_URI} !^/en
RewriteRule ^(.*)$ en/$1 [L]

Hopw can I leave the NL domain on the root while getting the .CO.UK to point to the EN folder, including the drupal rewrite rules.
Can someone help me out please?

Tx
Yoeri

[edited by: tedster at 9:00 pm (utc) on July 26, 2009]
[edit reason] switch domain name to "example" [/edit]

jdMorgan

9:54 pm on Jul 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Explicitly force canonicalization and prevent looping.

# Redirect non-canonical domain requests to canonical domain
RewriteCond %{HTTP_HOST} example\.co\.nl [NC]
RewriteCond %{HTTP_HOST} !^example\.co\.nl$
RewriteRule ^(.*)$ http://example.co.nl/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} example\.co\.uk [NC]
RewriteCond %{HTTP_HOST} !^example\.co\.uk$
RewriteRule ^(.*)$ http://example.co.uk/$1 [R=301,L]
#
# Rewrite example.co.nl URLs of the form '/x' to the form
# '/index.php?q=x' (Pass these requests to Drupal script)
RewriteCond %{HTTP_HOST} ^example\.co\.nl
RewriteCond $1 !^index\.php$
RewriteCond $1 !^favicon\.ico$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
#
# Rewrite example.co.uk URLs to /en subdirectory
RewriteCond %{HTTP_HOST} ^example\.co\.uk
RewriteCond $1 !^en/
RewriteRule ^(.*)$ en/$1 [L]

I added a few additional tweaks for server performance -- primarily avoiding file-exists checks unless necessary.

Jim

Yoerivdm

8:21 pm on Jul 28, 2009 (gmt 0)

10+ Year Member



Jim, thanks for the reply.
I did some more research and enabled rewritelogging giving me a tad more insight in the problem.

The only thing I need to do is:
rewrite http://www.example.nl/ to http://www.example.nl/nl/home

Drupal rewrite rules convert this url to .../index.php?q=nl/home

How can I reirect the root to /nl/home?

thanks
Yoeri

[edited by: jdMorgan at 9:16 pm (utc) on July 28, 2009]

jdMorgan

9:18 pm on Jul 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm sorry, this is not clear. Is this a new requirement in addition to the functions of the code your posted --and that I modified-- above?

Is this a third domain, or does your .nl domain NOT have a ".co" ahead of it?

Jim