.htaccess RewriteRule

两盒软妹~` 提交于 2019-12-13 07:24:40

问题


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:


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...



来源:https://stackoverflow.com/questions/8477275/htaccess-rewriterule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!