Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.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]
like image 473
Adrian Avatar asked Dec 30 '25 18:12

Adrian


1 Answers

Try this code :

RewriteCond %{HTTP_HOST} ^www.newdomain.com$
RewriteRule ^(.*)$  http://www.mydomain.com/sub-page [R=301,L]
like image 52
Lucas Willems Avatar answered Jan 06 '26 15:01

Lucas Willems



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!