1

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.

0

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-page$1 [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.com$1 [L,R=301,NC]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.