重定向子域(IE)时保留锚点 [英] Retain anchor when redirecting subdomain (IE)

查看:147
本文介绍了重定向子域(IE)时保留锚点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firefox:
http://example.com/about/#anchor ->

Firefox:
http://example.com/about/#anchor -> http://www.example.com/about/#anchor

Internet Explorer 6-8:
http://example.com/about/#anchor ->

Internet Explorer 6-8:
http://example.com/about/#anchor -> http://www.example.com/about/

为什么锚点在IE中掉线,我该怎么办? (不删除查询字符串,仅删除#xyz部分)

Why is the anchor dropped in IE and what can I do about it? (Query string is not dropped, only the #xyz part)

PHP标头或javascript重定向是我唯一的选择吗?感谢所有提示.

Is a PHP header or javascript redirect my only option? Thanks for all hints.

更新:似乎哈希没有发送到服务器.结合使用PHP 301标头和javascript重定向(与location.hash)是一个好的解决方案吗?

推荐答案

在Tomcat/JSP中也有类似的问题,不了解PHP.在Tomcat中,规则是#anchor仅用于浏览器/用户代理,因此您无法获取它.我的解决方法是在页面中使用Javascript来实现重定向.我的提示是,如果您很快无法在PHP中使用它,那么请尝试使用Javascript解决方法.

Had a similar problem in Tomcat/JSP, don't know about PHP. In Tomcat the rule was that the #anchor is only intended for the browser/user agent so you can't get it. My workaround was to use Javascript in the page instead to achieve the redirect. My tip would be that if you can't get it working in PHP soon then start trying a Javascript workaround.

这篇关于重定向子域(IE)时保留锚点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆