user3311391
user3311391

Reputation: 1

Setup an htacces file with 2 different redirects

I have got a domain called www.domain.nl I want to redirect www.domain.nl to newdomain.com/new all other urls from domain.nl for example www.domain.nl/old/ should redirect to www.newdomain.com/old/

and of course I want google to preserve my ranking (301)

Can anyone tell me what my htaccess file looks like.

thanks

Upvotes: 0

Views: 27

Answers (2)

markcial
markcial

Reputation: 9323

RewriteCond ${HTTP_HOST} domain.nl RewriteRule ^$ http://newdomain.com/ [R=301,L,QSA]

RewriteCond ${HTTP_HOST} domain.nl RewriteRule ^(.*)$ http://newdomain.com/old$1 [R=301,L,QSA]

(Untested)

Upvotes: 0

anubhava
anubhava

Reputation: 785156

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.nl$ [NC]
RewriteRule ^$ http://newdomain.com/new [L,R=301]

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

Upvotes: 1

Related Questions