开发者

Mod Rewrite question with regex's

开发者 https://www.devze.com 2022-12-19 16:12 出处:网络
Im trying to do this sort of rewrite that only affects some urls to make them go to anchors. So if I see this request:

Im trying to do this sort of rewrite that only affects some urls to make them go to anchors.

So if I see this request:

/somedir/trigger/something

I want to transform it to this request. I can guarantee there will be no slash after the trigger. The "something" 开发者_C百科part is going to be a alpha-numeric string every time. The "trigger" part is also alpha-numeric only, but I have multiple values for trigger. The "result" part is a constant alpha-numeric string that will never change.

/somedir/result#something

and the trigger can be maybe 4 or 5 different strings, but the result will always be the same. So I tried this:

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

i thought $1 would be the type it catches, and $2 to be the thing i want to find and stick at the end. This doesnt work though, and if anyone knows how to do this right that would help me out


This is not going to work. The hash is not part of the HTTP request, the browser will not transmit it, only use it internally to jump to the right position.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号