域不无`www`工作 [英] Domain doesn't work without `www`
本文介绍了域不无`www`工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我输入我的域名不一样的 WWW
(如 http://example.com
) ,这是行不通的,并给出错误信息。然而,当我添加了 WWW
来它(如 http://www.example.com
),它的工作原理
When I type in my domain name like without the www
(like http://example.com
), it doesn't work and gives error message. However, when I add the www
to it (like http://www.example.com
), it works.
这难道不是应该是双向的(有和没有 WWW
)?
Isn't it supposed to work both ways (with and without the www
)?
推荐答案
所有你需要的是增加以下code到根的.htaccess
文件:
All you need is to add the following code to your root .htaccess
file:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
这篇关于域不无`www`工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文