htaccess的非www到www 301 [英] .htaccess non-www to www 301

查看:229
本文介绍了htaccess的非www到www 301的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过重定向的.htaccess重写规则非www请求到www。

I redirected non-www request to www through .htaccess Rewrite Rule.

的RewriteCond%{HTTP_HOST}!^ WWW

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆