是否存在以下转发不起作用的情况?
我需要实施转发。我是按照以下方式完成的:
<html>
<head>
<meta http-equiv="refresh" content="0; URL=http://www.xyz.com">
</head>
<body>
</body>
</html>
是否有任何情况下这不起作用?我在 selfhtml.org 上阅读(http://de.selfhtml.org/html /kopfdaten/meta.htm#weiterleitung,抱歉,德语链接找不到另一个)这并不总是合适的。有没有更好的方法来做到这一点?在哪些情况下我的代码不起作用?
I need to implement a forwarding. I did it the following way:
<html>
<head>
<meta http-equiv="refresh" content="0; URL=http://www.xyz.com">
</head>
<body>
</body>
</html>
Are there any situations in which this won't work? I read on selfhtml.org (http://de.selfhtml.org/html/kopfdaten/meta.htm#weiterleitung, sry for the german link couldn't find another) that this isn't always appropriate. Are there any better ways to do this? And in which situations my code wouldn't work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,反对的主要论点是链接页面已经说过的内容:用户的浏览器可以关闭元重定向(尽管这种情况很少见),并且当用户尝试浏览历史记录时,立即重定向可能会导致可用性问题。
不过,如果可以的话,根本不输出任何 HTML,而是使用
location
标头进行服务器端重定向。在 PHP 中,它看起来像这样:如果你不能这样做,我会说使用元重定向就可以了。您可以添加几秒钟的暂停和一条消息(“您现在被重定向到......”),并结合链接,以最大程度地减少用户的烦恼。
至于搜索引擎优化,我预计搜索引擎会默默地忽略重定向页面,并继续对目标站点建立索引,这可能就是人们想要的。
Well, the major argument against is what the linked page already says: The user's browser could have meta redirects turned off (although this is going to be rare), and immediate redirects can cause usability problems when the user tries to navigate through the history.
If you can, though, don't output any HTML at all, but do a server-side redirect using the
location
header. In PHP, it would look like this:if you can't do that, I'd say using a meta redirect is fine. You could add a few seconds' pause and a message ("You are now being redirected to...."), combined with a link, to minimize annoyance for users.
As for Search engine optimization, Search engines, I expect, will silently ignore the redirecting page, and go on indexing the target site, which is probably what one wants.