简体   繁体   中英

permanently redirect all pages of sub-domain to main domain .htaccess

I want to redirect all urls of sub-domain to main-domain, like m.abc-xyz.com/test1 to abc-xyz.com/test1 and m.abc-xyz.com/test2 to abc-xyz.com/test2 and so on.... I have this code in root .htaccess file which only works for m.abc-xyz.com to abc-xyz.com

RewriteCond %{HTTP_HOST} ^m\.abc\-xyz\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.m\.abc\-xyz\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.abc\-xyz\.com" [R=301,L]

Most likely because you have [OR] only after first condition, so it's: first condition is true or all other are true (at the same time) which is not happening. Try adding [OR] at all places where it should be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM