htaccess的重写规则 [英] .htaccess RewriteRule
问题描述
我试图写一个重写规则(没有运气),将采取字符串的散列后和重写它作为查询字符串参数。事情是这样的......
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
和重写这个...
<$c$c>http://www.example.com/locations/details.aspx?id=7F1A6245-3BE3-62D5-A4B6-60C5D599BF21$c$c>
我使用的是用IIS7 .htaccess文件,所以我pretty的肯定那就是你的。htaccess的使用与Apache相同的正则表达式。感谢您的帮助!
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!
修改
这是我没有...
重写规则^ /位置/(.*)/(.*)$ /locations/details.aspx\?id=$2 [NC,L,U]
...这就像一个魅力。由于乌尔里希!
...and that works like a charm. Thanks Ulrich!
推荐答案
不幸的是,你不能做到这一点。片段标识符不被发送到服务器。从维基百科
Unfortunately, you cannot do this. The fragment identifier is not transmitted to the server. From Wikipedia
客户端不应该URI片段发送到服务器时,他们检索文档
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...
这篇关于htaccess的重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!