Forum Moderators: phranque

Message Too Old, No Replies

htaccess rewrite question

         

ptriek

7:44 am on Jun 3, 2011 (gmt 0)

10+ Year Member



The situation:

- I have a multisite Drupal 6 setup with 2 domains (domain1.com en domain2.com)
- Domain 1 is in three languages (DU/EN/FR), domain 2 is in 1 language (Dutch only).

The problem:

- Google has indexed domain2.com/en and domain2.com/fr - so many visitors see English or French terms on a Dutch website.
- Client is not happy.

The solution (I hope):

- I would like to modify the .htaccess file, and send all visitors on domain2.com to /du
- My knowledge of htaccess rewrite is limited, and I can't get it working.

Below is the most recent version of my code - the first 3 lines are my addition, the last 4 lines are Drupal-specific - but it doesn't really work (endless loop).


# disable EN+FR:
RewriteCond %{HTTP_HOST} ^(www.)?domain2.com$ [NC]
RewriteRule ^(/)?(.*)$ /du

# 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]


The question:

- Ideas, anyone?

g1smd

8:22 am on Jun 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Make a very clear list of what actions should be taken for EVERY possible domain/folder combination. It isn't 100% clear what you want to do.

List URLs where action is to be taken AND where it is not supposed to be taken.

Use example.com and example.net to stop forum auto-linking.

Redirects need the [R=301,L] flag and the target should include the domain name. Internal rewrites need only the [L] flag.

However, do not proceed to coding until the requirements have been laid out in detail.

ptriek

8:38 am on Jun 3, 2011 (gmt 0)

10+ Year Member



I'm sorry if I wasn't clear, I'll add some more details:

- example.com is in 3 languages (du/en/fr) - no change is needed

- example.net is in 1 language (du)

- all users visiting example.net (without folder) should be redirected to example.net/du

- all users visiting example.net/* (without language string) should be redirected to example.net/du/*

- all users visiting example.net/en/* and example.net/fr/* should be redirected to example.net/du/*

- all users visiting example.net/du : no change needed

- all users visiting example.net/du/* : no change needed

- after that, the rewritten string should be processed by the Drupal-specific rule, resulting in a Dutch-only website.

# disable EN+FR:
RewriteCond %{HTTP_HOST} ^(www.)?example.net$ [NC]
RewriteRule ^(/)?(.*)$ /du

# 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]

g1smd

7:37 pm on Jun 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You will need a LOT more rules than that.

The rules will need to test what was actually requested. That is, (.*) is not the right pattern.