.htaccess RewriteRule

2019-09-01 03:02发布

I'm trying to write a rewriteRule (with no luck) that would take the string after the hash and rewrite it as a querystring parameter. Something like this...

http://www.example.com/locations/new-york#7F1A6245-3BE3-62D5-A4B6-60C5D599BF21

and rewrite to this...

http://www.example.com/locations/details.aspx?id=7F1A6245-3BE3-62D5-A4B6-60C5D599BF21

I'm using iis7 with .htaccess file, so I'm pretty sure it's the same regex that you would use for .htaccess with apache. Thanks for the help!

EDIT

Based on Ulrich Palha's answer here's what I did...

RewriteRule ^/locations/(.*)/(.*)$ /locations/details.aspx\?id=$2 [NC,L,U]

...and that works like a charm. Thanks Ulrich!

1条回答
你好瞎i
2楼-- · 2019-09-01 03:29

Unfortunately, you cannot do this. The fragment identifier is not transmitted to the server. From Wikipedia

Clients are not supposed to send URI-fragments to servers when they retrieve a document

Therefore you will not be able to process it on the server side...

查看更多
登录 后发表回答