问题描述
我通过重定向的.htaccess重写规则非www请求到www。
I redirected non-www request to www through .htaccess Rewrite Rule.
的RewriteCond%{HTTP_HOST}!^ WWW
重写规则(。*)的www。%{HTTP_HOST} / $ 1 [L,R = 301]
RewriteRule (.*) www.%{HTTP_HOST}/$1 [L,R=301]
但现在我有问题的子域。当我访问touch.111.com然后在它上面的规则重定向到touch.www.111.com(是不是触摸设备访问和网站的休息时间)。
But now I am having problems with sub domain. When I am accessing touch.111.com then it above rule redirect to touch.www.111.com (Which is not accessible and website break on touch devices).
请指点我来解决上述问题。
Please advice me to fix above problem.
感谢
推荐答案
您必须如果要重定向仅 domain.com
到具体www.domain.com
并保留子域名(如 touch.domain.com
):
You must be specific if you want to redirect only domain.com
to www.domain.com
and retain sub-domains (such as touch.domain.com
) :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]
这篇关于htaccess的非www到www 301的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!