views:

1402

answers:

7

Hello everyone,

One of our website has URL like this : exemple.oursite.com. We decided to move our site with an URL like this www.oursite.com/exemple. 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 exemple.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 ?

Thanks a lot in advance

A: 

You could create a page on the old address that catches all requests and redirects to the new site with the correct address and code.

I did something like that, but it was in asp.net, which I guess it's not the language you use. Anyway there should be a way to do this in any language.

rslite
A: 

When returning status 301, your server is supposed to return a 'Location:' header which points to the new location. In practice, the way this is implemented varies; some servers provide the full URL (netloc and path), some just provide the new path and expect the browser to look for that path on the original netloc. It sounds like your rewrite rule is stripping the path.

An easy way to see what the returned Location header is, in the python shell:

>>> import httplib
>>> conn = httplib.HTTPConnection('exemple.oursite.com')
>>> conn.request('HEAD', '/')
>>> res = conn.getresponse()
>>> print res.getheader('location')

I'm afraid I don't know enough about mod_rewrite to tell you how to do the rewrite rule correctly, but this should give you an idea of what your server is actually telling clients to do.

Meredith L. Patterson
+2  A: 

I am fairly certain that the hash/page anchor/bookmark part of a URL is not indexed by search engines, and therefore has no effect on your page ranking. Doing a google search for "inurl:#" returns zero documents, so that backs up my assumption. Links from external sites will be indexed without the hash.

You are right in that the hash part isn't sent to the server, so as far as I am aware, there isn't a good way to be able to create a redirection url with the hash in it.

Because of this, it's up to the browser to correctly manage the hash during a redirect. Firefox 3.5 appears to do this successfully. If you append a hash to a URL that has a known redirect, you will see the URL change in the address bar to the new location, but the hash stays on there successfully.

Edit: In response to the comment below, if there isn't a hash sign in the external URL for the part you need, then it is entirely possible to rewrite the URL. An Apache rewrite rule would take care of it:

RewriteCond %{HTTP_HOST}   !^exemple\.oursite\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.oursite.com/exemple/$1 [L,R]

If you're not using Apache, then you'll have to look into the server docs for something similar.

zombat
You are right, SE don't index the hash part. But exemple, someone on his website could post a link to a video on our site.(exemple.oursite.com/video_id=233) The link should continue to work to allow websurfer to play our video but the ranking to exemple.oursite.com needs to be transfered to www.oursite.com/exemple
The example you just gave in your comment lacks a hash sign, so it's much different than your original question. If that's the URL you want to rewrite, then that is possible and I will update my answer. You should clarify your question if this is the case.
zombat
A: 

Hello, I registered my account so I can't edit.

zombat : I'm sorry I made a mistake in my comment. The link to our video is exemple.oursite.com/#video_id=233. In this case, my rewrite rule in Apache doesn't work.

Nick Berardi: We changed the way our links work. We don't use # anymore, only for backward compatibility

Mike
You are pretty much up a creek with out a paddle on backward comparability. The only way I see you redirecting the user is through JavaScript, however that isn't going to solve your search bot issue, but like others have said the search bot is only concerned with the requestable part of the URL, which doesn't include the hash tag.
Nick Berardi
A: 

The search bots don't care about hash tags. And if you are using them for some kind of flash or AJAX calls, you have more serious problems than your 301 redirects don't work. Because unless you have the content in an alternate form, the search engines are not indexing your site and you are definitely suffering as far as SEO goes.

Nick Berardi
The flip side of that coin is that you can rely on the SE non-indexation of the hash to canonicalize similar content (rand fishkin does a decent explanation here: http://www.seomoz.org/blog/whiteboard-friday-using-the-hash) and then rely on js to do your tracking
TMG
A: 

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 unfortunatelye 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://www.mikeduncan.com/named-anchors-are-not-sent/

Martindale
A: 

Google has a special syntax for AJAX applications that is based on hash URLs: http://code.google.com/web/ajaxcrawling/docs/getting-started.html

kkaefer