![](/img/trans.png)
[英]Is it better to 301 redirect requests to a www. subdomain or non-www?
[英]301 when www. infront of subdomain
任何人都可以解释重定向条件和实现此目标的规则:
(基本上从网址中删除www。,但仅在他们访问子域时才删除。
它必须允许访问www.domain.com
谢谢!
将其添加到htaccess文件中:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([^\.]*)\.domain\.com$ [NC]
RewriteRule (.*) http://%1.domain.com/$1 [R=301,L]
会将www.example.domain.com
重定向到http://example.domain.com
,甚至会将www.other.domain.com
重定向到http://oter.domain.com
尝试这个,
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([a-zA-Z0-9]+)\.domain\.com [NC]
RewriteRule ^(.*)$ http://%1.domain.com/$1 [L,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.