你可以写301重定向到一个锚点? [英] Can you write a 301 redirect to an anchor point?

查看:494
本文介绍了你可以写301重定向到一个锚点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是有效的,正确的?

RewriteRule ^myOldPage.html$ /index.php#info [R]

我对 #info 部分特别感兴趣。

推荐答案

是的。这是一个有效的301重定向( HTTP标准允许任何有效的URI作为重定向提供)。

Yes. That's a valid 301 redirect (the HTTP standard allows for any valid URI to be provided as the redirect).

现在的告诫:并非所有的搜索引擎可能会喜欢的重定向。谷歌并处理锚标记了出色的工作(他们甚至有一个<一个href=\"http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&u=/netahtml/PTO/search-adv.htm&r=1&p=1&f=G&l=50&d=PTXT&S1=7,308,643.PN.&OS=pn/7,308,643&RS=PN/7,308,643\"相对=nofollow在这个>专利),而其他人将完全忽略他们。只要这不是一个问题,重定向在技术上是有效的。

Now the caveat: Not all search engines may love the redirect. Google does a fantastic job of handling anchor tags (they even have a patent on this), while others will completely ignore them. As long as that's not an issue, the redirect is technically valid.

更新:如果您遇到与mod_rewrite的麻烦,从得到EN codeD尝试NE(无路可逃)标志,以prevent#符号:

Update: If you're having trouble with mod_rewrite, try the NE (no escape) flag to prevent the # symbol from getting encoded:

RewriteRule ^myOldPage.html$ /index.php#info [R,NE]

这篇关于你可以写301重定向到一个锚点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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