Stichy
Stichy

Reputation: 1515

Two domains one site .htaccess rewrite

I have a site with two similar domain names. The problem is that Google is indexing this as two different sites.

How do I point the one domain to another?

foo.se/example should go to bar.se/example

I have tried this in .htaccess:

RewriteCond %{HTTP_HOST} ^foo.se
RewriteRule ^(.*)$ http://bar.se/$1 [R=permanent,L]

But foo.se/example only leads to bar.se (without sub directory)

Any ideas? Thanks!

Upvotes: 1

Views: 34

Answers (1)

anubhava
anubhava

Reputation: 785266

Try this rule with %{REQUEST_URI} instead of $1:

RewriteCond %{HTTP_HOST} ^foo\.se$ [NC]
RewriteRule ^ http://bar.se%{REQUEST_URI} [R=301,NE,L]

Upvotes: 1

Related Questions