Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite to hide # in anchor links

         

cantona

9:54 am on Sep 8, 2008 (gmt 0)

10+ Year Member



Hi, I'm not sure if this is possible as # seems to break the rule and encoding it to %23 doesn't work either.

I have a page with several anchor links...

<a href="#fruit-apple"... blah 
<a href="#fruit-banana"... blah

Obviously, the hash is appended to my query string along with the anchor. But, I want this to work without having the hash in the URL. Is there a way I can do a redirect with mod_rewrite?

I've tried


RewriteRule resources/(.*) /resources/#$1 [L]
and even
RewriteRule ^food/fruit-apple$ /food/#apple [R=301,L]

Any ideas?

g1smd

10:01 am on Sep 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use the Live HTTP Headers extension for Mozilla Firefox and Mozilla Seamonkey to see what is sent to the browser...

Fragment IDs are resolved internally by the browser and not by the server.

If you want to see stuff in the query string you will need to test %{QUERY_STRING} in your rules, as that is not a part of the path directly seen by Mod_Rewrite, but something added to the end of the path.