Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite internal anchors don't work?

i.e. www.xyz.com#anchor

         

waca

7:13 am on Jan 1, 2006 (gmt 0)

10+ Year Member



I have some simple redirect rules as follows:

RewriteBase /
RewriteRule ^abc$ /page.php [L]
RewriteRule ^xyz$ /page.php#xyz [L]

Unfortunately it seems to completely ignore the "#xyz" as part of the rewrite - it just takes me to page.php

Is this because # is a comment character? If so, how to get around this obvious problem? If not, what am I doing wrong?

I would have searched the forum but couldn't figure out how to....

Thanks in advance for any and all help! :)

jdMorgan

7:20 am on Jan 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Local anchors are processed only 'inside' the client (browser), and so have no meaning in the context of mod_rewrite on the server. The behaviour you observe is completely normal.

For example, if you link to page.php#foo, and someone clicks that link, their browser will request page.php from your server, and after loading that page, the browser will then 'jump' to the '#foo' anchor.

The usual solution to this problem is to break the page into multiple pages, so that you can more-selectively link to the content.

Jim

waca

7:45 am on Jan 1, 2006 (gmt 0)

10+ Year Member



Had a feeling that might be the case.

Thank you very much for your excellent - and extremely timely - reply. :)

Just discovered the forum tonight and am in awe.