English 中文(简体)
"Mod Rewrite"问题与正则表达式s。
原标题:Mod Rewrite question with regex s

我正在尝试进行此类型的重写,仅影响某些网址以使它们转到锚点上。

所以如果我看到这个请求:

/somedir/trigger/something

我想将其转换为此请求。 我可以保证触发器后面不会有斜杠。 “something”部分每次都会成为字母数字字符串。 “trigger”部分也仅限于字母数字,但我有多个触发器值。 “result”部分是一个恒定的字母数字字符串,永远不会改变。

/somedir/result#something

触发器可能是4或5个不同的字符串,但结果总是相同的。所以我尝试了这个:

RewriteRule ^/somedir/(type1|type2|type3|type4)/(.*)$ /somedir/result#$2

我原以为$1是要捕捉的类型,$2是想找到并附加到末尾的内容。但这并不起作用,如果有人知道正确的方法,请帮我解决。

问题回答

这样行不通。哈希不是HTTP请求的一部分,浏览器不会传输它,只是在内部使用它来跳转到正确的位置。





相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签