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.

asked Feb 11, 2019 at 6:17

1 Answer 1

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-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]
answered Feb 11, 2019 at 8:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.