Jan Jankowski Janek
Jan Jankowski Janek

Reputation: 57

Htacces - redirecting selected

I have 2 domains (domain1.com and domain2.com).

I want to make such redirects:

a) few specific subpages in domain1.com redirect to specific subpages in domain2.com

b) other subpages from domain1.com redirect to specific subpage in domain2.com .

My htacces dont work propoerly. What i can change in this htacces?

RewriteCond %{HTTP_HOST} ^domain1.com$ [nc]
RewriteRule domain1.com/a http://domain2.com/ssd [R=301,L]
RewriteRule domain1.com/ad http://domain2.com/ssw [R=301,L]
RewriteRule ^(.*)$ http://domain2.com [R=301,L]

Upvotes: 0

Views: 119

Answers (1)

anubhava
anubhava

Reputation: 786349

You cannot match domain name in RewriteRule.

You can use these rules:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC]
RewriteRule ^a(/.*)?$ http://domain2.com/ssd [R=301,L,NC]

RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC]
RewriteRule ^ad(/.*)?$ http://domain2.com/ssw [R=301,L,NC]

RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC]
RewriteRule ^ http://domain2.com [R=301,L,NC]

Upvotes: 0

Related Questions