开发者

Apache URL rewrite query

Can anyone tell me how to do this? i'm stumped!

I need a modified URL in this format

this55-is-a-test-id-23.html

But I need the 23 as a GET. I can't rely on searching for 'id' as this may occur elsewhere in the URL. Is there any way of searching for the last occurrence of id开发者_如何学运维 and passing that as a get using an Apache RewriteRule in .htaccess??

Many thanks

Ant


I'm not able to test it right now, but

RewriteRule ^.*-id-(.*?)\.html$ index.php?id=$1 [L]

should get everything between the last "-id-" in the URL and ".html" and pass it to index.php (change it to fit your needs) as id via get.

(Notice the ? after .*, it makes the regular expression non-greedy, so that it matches as fewer characters as possible, making sure it's the last occurrence of "-id-")

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜