Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have some URIs which have been published or shared which I now need to redirect. The old urls take the form:

http://www.mysite.com/!#story/45 and I want to redirect them to http://www.mysite.com/#!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

OR

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 superuser.com Oct 20 '11 at 17:12

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

2  
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 - mikeduncan.com/named-anchors-are-not-sent –  codecowboy Oct 20 '11 at 13:57
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.