Apache 2.2 HTTP_HOST无法正确解析为localhost

时间:2013-02-04 12:44:07

标签: .htaccess mod-rewrite apache2 localhost http-host

显然整个问题是chrome v.24和主机解析中新引入的错误,htaccess在任何其他浏览器中都能正常工作。 不知道如何“关闭”这个问题,如果有人能指出我的话^^

尝试使用在Windows上本地运行的Apache 2.2进行简单的重写。

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

重定向到“www.localhost /”

第一行不应该与localhost匹配吗?

还尝试了这些替代方案:

1
RewriteCond %{REMOTE_ADDR} !127.0.0.1
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

2
RewriteCond %{HTTP_HOST} !^(www\.|localhost$) [NC]  
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

3
RewriteCond %{HTTP_HOST} !^(www\.|127.0.0.1$) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

4
RewriteCond %{HTTP_HOST} !^(www\.|localhost$) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

5
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^localhost$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

6
RewriteCond %{HTTP_HOST} !^localhost$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

每一个人都去“www.localhost /”,任何人都知道出了什么问题?

0 个答案:

没有答案
相关问题