Jump to content

[SOLVED] mod_rewrite with # in regex pattern


lazylester

Recommended Posts

I'm using mod_rewrite to manipulate requests that look like this: www.mydomain.com/myfile.html#someanchor

 

I would like the anchor name ("someanchor") to appear as a $_GET parameter, so rewrite the filename to myfile.html?anchor=someanchor

 

However the mod_rewrite regex pattern seems to fail with the #.  I've tried my regex expressions on other regex engines (e.g. php) and it finds the pattern, but in mod_rewrite, the # seems to terminate the pattern search. For example, if I request the file myfile.htmlmyanch#or to this:

 

          RewriteRule ^(.*).html([a-z#]*) test.html\?position=$2

 

the variable in $2 is "myanch" (even if I escape the # in the regex pattern, which I don't believe is necessary, but tried anyway)

 

Can anyone shed any light on this, please? thanks in advance

 

Les

 

I've learned that the "fragment identifier" appended to a URI with the "#" prefix, is not sent to the server by the browser. Instead it is retained by the browser and used to navigate to a reference within the returned document when the server responds.

 

That's why I couldn't match it with the mod_rewrite regex.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.