Redirect a subdomain url that has a CNAME

2019-09-06 09:51发布

问题:

I am looking to 301 redirect a single url on a subdomain to a url on the root domain. Eg:

'sub.domain.com/page' to redirect to 'domain.com/work/name'

I do not want to affect any other pages on the subdomain, the subdomain should operate as normal, aside from that one specific url.

The subdomain also has a CNAME record with the value 'shopname.bigcartel.com'

I tried the .htaccess suggested in my previous question here, but that was before I knew there was also a CNAME record active.

How can I achieve the redirection?

Thanks in advance. Darrell

回答1:

Add such strings to .htaccess in root of sub.domain.com, not in root of domain.com

RewriteEngine On
RewriteRule ^page$ http://domain.com/work/name [L,R=301]

Must work