我正在尝试为几个根域设置redirect。
首先,这是我的httpd-vhosts.conf文件中的代码:
<VirtualHost *:80> ServerAdmin ****@example.com ServerName example.com ServerAlias example2.com RewriteEngine On RewriteCond %{HTTP_HOST} !^192\.168\.0\.1$ # This is our WAN IP RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] </VirtualHost>
这样做是将example.com或example2.com的根域或www以外的任何主机redirect到www.example.com(2).com
我遇到问题的部分是RewriteRule本身。 $ 1应该与RewriteRule的模式相匹配,并将其添加到replace中。 例如:“ http://example.com/test.html ”应该重写为“ http://www.example.com/test.html ”
它适用于所有现代浏览器,除了IE8或IE9外(我没有testing其他IE版本)。
在IE中,这是有效的:“ http://example.com ”为“ http://www.example.com ”
在IE中,这是行不通的:“ http://example.com/test.html ”到“ http://www.example.com/test.html ”
有没有人有这种行为的解释?
我希望我已经解释得很好。
谢谢。
把这个代码放在htaccess中为我修正了一个类似的问题:
BrowserMatch "MSIE [2-8]" nokeepalive downgrade-1.0 force-response-1.0