tortuga
tortuga

Reputation: 414

.htaccess permanent redirect (301) problem

I'm trying to redirect the www and non-www version of my .fr url to a .com url. the www works, but I can 't get the non-www working. Any idea why the non-www Rewrite isn't working?

RewriteCond %{HTTP_HOST} ^www\.domain\.fr$
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.fr$
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

Complete .htaccess

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.44

RewriteEngine on
RewriteLogLevel 0
LogLevel debug 
RewriteBase /


RewriteCond %{HTTP_HOST} ^(www\.domain\.fr|domain\.fr)$
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.domain.co.uk [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.domain.org [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.domain.net [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.domain.de [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.domain.eu [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteRule ^nl/js/(.*)$ /js/$1 [L, NC]
RewriteRule ^fr/js/(.*)$ /js/$1 [L, NC]
RewriteRule ^en/js/(.*)$ /js/$1 [L, NC]

RewriteRule ^nl/images/(.*)$ /images/$1 [L, NC]
RewriteRule ^fr/images/(.*)$ /images/$1 [L, NC]
RewriteRule ^en/images/(.*)$ /images/$1 [L, NC]

And a bunch of rewrite rules like this

RewriteRule ^nl/news.asp$ n_news.asp [R]
RewriteRule ^fr/news.asp$ f_news.asp [R]
RewriteRule ^en/news.asp$ e_news.asp [R]

Upvotes: 0

Views: 665

Answers (1)

LazyOne
LazyOne

Reputation: 165298

As I understand (based on your htaccess) all what you want to do is to redirect ANY configured domain name to www.domain.com.

In this case try this single rule instead of separate rule for each TLD (co.uk, .org, .eu etc) that you have:

RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

So anything that is not www.domain.com will be redirected to it.

Upvotes: 1

Related Questions