简体   繁体   中英

Using htaccess to redirect all subdomains except one

current htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite.co.uk [NC]
RewriteRule ^(.*)$ http://www.mywebsite.co.uk/$1 [L,R=301,NC]

I also have a subdomain : m.mywebsite.co.uk I don't want this "m." domain redirected, but all other subdomains that exist or not directed to www.mywebsite.co.uk including "mywebsite.co.uk"

Can you help? thanks

Try :

RewriteEngine on
RewriteCond %{HTTP_HOST} !^m\.mywebsite\.co\.uk$
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.co.uk/$1 [L,R=301,NC]

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