Could anyone please explain the redirect conditions and rule to achieve this:
(Basically removing the www. from the URL, but ONLY when they access a subdomain.
It must allow access at www.domain.com
Thanks!
Adding this to the htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([^\.]*)\.domain\.com$ [NC]
RewriteRule (.*) http://%1.domain.com/$1 [R=301,L]
will redirect www.example.domain.com
to http://example.domain.com
it will even redirect www.other.domain.com
to http://oter.domain.com
Try this,
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([a-zA-Z0-9]+)\.domain\.com [NC]
RewriteRule ^(.*)$ http://%1.domain.com/$1 [L,R=301]
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.