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

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

问题描述

我们的其中一个网站的网址如下: example.oursite.com 。我们决定使用像 www.oursite.com/example 这样的网址来移动我们的网站。要做到这一点,我们在我们的Apache服务器中编写了一个重写规则,重定向到我们的新网址,代码为301.



许多网站都链接到我们,网址为 example.oursite.com/#id=23 。问题是重定向会用IE清除URL的散列部分。据我所知,哈希部分永远不会发送到服务器。



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



我希望搜索引擎得到我们的新网址(301)的通知,因为我们需要将网页等级转移到我们的新网址。 / p>

有没有办法用301代码重定向,并保留in的哈希部分(#id = 23 )搜索引擎确实关心哈希标签,他们经常使用它们来突出显示页面上的特定内容。

然而,对于这个问题,不幸的是锚定位置不会作为HTTP请求的一部分发送到服务器。如果你想重定向一个用户,你需要在客户端使用Javascript。



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


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.

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.

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)

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.

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.

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.

Good article: http://web.archive.org/web/20090508005814/http://www.mikeduncan.com/named-anchors-are-not-sent/

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

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