【问题标题】:htaccess rewrite condition not working in internet explorerhtaccess 重写条件在 Internet Explorer 中不起作用
【发布时间】:2015-05-29 14:53:17
【问题描述】:

我们有多个使用相同代码的网站。问题是这在 Firefox、Chrome 等中可以正常工作,但在 IE 中无法正常工作。

我的建议是 Internet Explorer 发送不同/不正确的 HTTP_HOST。但我不知道为什么。任何人都可以帮助我朝着正确的方向前进。 我已经在下面发布了 htaccess 文件

代码应该做什么: 1.检查请求是否针对站点地图 2.将www重定向到http 3. 如果网站不是 website.nl 使用 http 4. 如果网站是 website.nl 使用 https 5.所有请求都使用request.php文件

RewriteEngine On

RewriteBase /

RewriteRule ^sitemap\.xml/?$ generate_sitemap.php [NC,L]

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

RewriteCond %{HTTP_HOST}  !^(www\.)?website.nl$ [NC]
RewriteCond %{HTTP_HOST}  ^$
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?website.nl$ [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((.|/)*)$ /request.php?path=$1 [QSA,L]

【问题讨论】:

    标签: apache .htaccess internet-explorer


    【解决方案1】:

    与 Chrome 和 Firefox 相比,Internet Explorer 不太可能发送另一个 host 标头。您可能看到的是 Internet Explorer 缓存了一个旧的错误的重写规则(您正在使用301 永久重定向,它们被缓存在浏览器中)。也可能是 Chrome 和 Firefox 缓存了旧规则。

    清除浏览器缓存或使用私密/隐身模式,然后重试。

    我可以推荐使用302 临时重定向,直到您验证所有规则都正常工作。

    如果以上内容确实可以帮助您解决问题:

    你可以在这里测试你的重写规则:http://htaccess.madewithlove.be

    您可以在 Internet Explorer 的开发者控制台中按 F12 / 网络视图查看请求标头,包括 Host 标头。

    同时检查 Internet Explorer 和调制解调器/路由器设置,以确认您没有意外使用代理。

    【讨论】:

    • 我发现它陷入了无限循环。仅在 Internet Explorer 中。它一直连接到website.nl。所以我一直在执行角色 https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    • 找到解决方案:必须将 HTTPS != 更改为 RewriteCond %{SERVER_PORT} !443 非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-07
    相关资源
    最近更新 更多