使用哈希部分(锚点)重定向 301 # [英] Redirect 301 with hash part (anchor) #

查看:16
本文介绍了使用哈希部分(锚点)重定向 301 #的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的一个网站有这样的 URL:example.oursite.com.我们决定使用这样的网址来移动我们的网站 www.oursite.com/example.为此,我们在 Apache 服务器中编写了一个重写规则,该规则使用代码 301 重定向到我们的新 URL.

One of our website has URL like this : example.oursite.com. We decided to move our site with an URL like this www.oursite.com/example. To do this, we wrote a rewrite rule in our Apache server that redirect to our new URL with a code 301.

许多网站通过 example.oursite.com/#id=23 形式的 URL 链接到我们.问题是重定向使用 IE 擦除了 URL 的哈希部分.据我所知,哈希部分永远不会发送到服务器.

Many websites link to us with URLs of the form example.oursite.com/#id=23. The problem is that the redirection erase the hash part of the URL with IE. As far as I know, the hash part is never sent to the server.

我想用 javascript 实现重定向以保留哈希部分,但搜索引擎不会知道我们的 URL 已更改.(没有返回代码 301)

I wanted to implement the redirection with javascript to keep the hash part, but the Search Engine will not be aware that our URL changed. (no code 301 returned)

我希望将我们的新 URL (301) 通知搜索引擎,因为我们需要将页面排名转移到我们的新 URL.

I want the Search Engine to be notified of our new URL(301) because we need to transfer the page rank to our new URL.

有没有办法使用 301 代码重定向并保留 URL 中的哈希部分(#id=23)?

Is there a way to redirect with a 301 code and keep the hash part(#id=23) of in the URL ?

推荐答案

搜索引擎实际上关心哈希标签,他们经常使用它们来突出显示页面上的特定内容.

Search engines do in fact care about hash tags, they frequently use them to highlight specific content on a page.

然而,遗憾的是,锚位置不会作为 HTTP 请求的一部分发送到服务器.如果您想重定向用户,则需要在客户端使用 Javascript 执行此操作.

To the question, however, anchor locations are unfortunately not sent to the server as part of the HTTP request. If you want to redirect a user, you will need to do this in Javascript on the client side.

好文章:http://web.archive.org/web/20090508005814/http://www.mikeduncan.com/named-anchors-are-not-sent/

这篇关于使用哈希部分(锚点)重定向 301 #的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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