Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some URIs which have been published or shared which I now need to redirect. The old urls take the form:!#story/45 and I want to redirect them to!story/name-of-the-story

I've tried the following in a .htaccess file (Apache 2.2)

redirect 301 /#!story/45 /#!story/name-of-the-story


RewriteCond %{REQUEST_URI} ^(.*)#!story/45(.*)$
RewriteRule ^(.*)$ /#!story/name-of-the-story [R=301]

But this does not redirect the URL (it just has no effect). The !# syntax is generated by a library we are using called prettyPhoto which writes location hash from javascript :

location.hash = decodeURI('!' + theRel + '/'+story_slug+'/');

Can anyone explain why this wouldn't work or suggest a way round this? I have mod_rewrite enabled.

share|improve this question

migrated from Oct 20 '11 at 17:12

This question came from our site for computer enthusiasts and power users.

And that's the reason you don't use hashes for this. They aren't actually part of the request URL. – Daniel Beck Oct 20 '11 at 13:21
Yep - just found a similar question over on SO. And this - – codecowboy Oct 20 '11 at 13:57
up vote 1 down vote accepted

Not possible. Anchors aren't part of the URI or Query String, so they aren't sent to Apache at all.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.