I am trying to redirect an alias url to a different url path. (it wont let me do this in cpanel for some reason)
Example: SiteX.com> SiteY.com/this-page
I have tried
RewriteCond %{HTTP_HOST} ^sitex.com [NC] 
RewriteRule ^(.*)$ https://www.sitey.com/this-page 1ドル [L,R=301,NC]
At the moment I can only work out to redirect sitex.com to sitey.com
Everything I try wont let me point to SiteY.com/this-page
So the result is that SiteX after redirect just goes to the base url for SiteY.com
I am sure its very easy to achieve but all answers I find are regarding sub folders and not url-friendly sub paths.
1 Answer 1
You have one mistake in our RewriteRule: 1ドル contains the match of your regular expression, in your case the complete request path.
Now, if you want to append it to https://www.sitey.com/this-page you have to remove the space, so the correct rule would be:
RewriteCond %{HTTP_HOST} ^sitex.com [NC] 
RewriteRule ^(.*)$ https://www.sitey.com/this-page1ドル [L,R=301,NC]
This would redirect for example https://sitex.com/mypath to https://www.sitey.com/this-page/mypath
If you want to redirect every request to sitex.com to the same page (https://www.sitey.com/this-page), then you have to remove 1ドル.
If xou want to redirect https://sitex.com/mypath to https://www.sitey.com/mypath the correct RewriteRule is
RewriteCond %{HTTP_HOST} ^sitex.com [NC] 
RewriteRule ^(.*)$ https://www.sitey.com1ドル [L,R=301,NC]