网页有一个重定向循环www到非www

时间:2015-06-07 15:09:23

标签: linux .htaccess debian

我在debian 7上安装了灯,但我需要一个非www网址,现在我的网站总是添加www。前

ServerAdmin webmaster@localhost
ServerName www.example.com (the same issu with example.com)
ServerAlias example.com *.example.com
DocumentRoot /home/site/www
<Directory />
        Options FollowSymLinks
        AllowOverride All
</Directory>
<Directory /home/site/www>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

我也用htaccess测试但是浏览器给我循环

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

为什么apache添加www?它的新配置我只启用了一个站点。

由于

1 个答案:

答案 0 :(得分:0)

确保域example.com实际上是通过DNS解析的 (而不只是www.example.com

现代浏览器(以及不那么现代的浏览器)如果无法解析,会尝试自动更正域名。

除此之外,这意味着他们会尝试将www.添加到域名中。