Adrian
Adrian

Reputation: 2012

how to redirect new domain to sub page of old domain in htaccess

I have a wordpress site which is www.mydomain.com . This site has a page www.mydomain.com/sub-page

I also have a new domain, www.newdomain.com which is pointed to the same root/site, but I want people that use this domain to get redirected to www.mydomain.com/sub-page

Here is my htaccess, Im not sure of the syntax, but at the moment this is doing nothing, www.newdomain.com simply loads www.mydomain.com

RewriteCond %{HTTP_HOST} ^www\.newdomain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^newdomain\.com$ [NC]
RewriteRule ^(.*)$  http://www.mydomain.com/sub-page [R=301,L]

Upvotes: 3

Views: 2656

Answers (1)

Lucas Willems
Lucas Willems

Reputation: 7073

Try this code :

RewriteCond %{HTTP_HOST} ^www.newdomain.com$
RewriteRule ^(.*)$  http://www.mydomain.com/sub-page [R=301,L]

Upvotes: 5

Related Questions