开发者

Rewriting URL rule, example like StackOverflow

开发者 https://www.devze.com 2023-02-18 21:38 出处:网络
What would be the apache rewrite url to extract the id number (434376) from this url? http://stackoverflow.com/questions/434376/unique-url-slug

What would be the apache rewrite url to extract the id number (434376) from this url?

http://stackoverflow.com/questions/434376/unique-url-slug

something like

R开发者_开发技巧ewriteEngine On  
RewriteRule ^questions/([0-9]+)/?$([A-Za-z0-9-]+)   post.php?post_id=$1 [NC,L]  

...but it doesnt work on my site...any tips?

thanks


Tested:

RewriteRule ^questions/([0-9]+)/?.*$   rewrite.php?post_id=$1 [NC,L]


Well if the / is optional it probably should be:

RewriteRule ^questions/([0-9]+)/?([A-Za-z0-9-]+)?/?$   post.php?post_id=$1 [NC,L]

Let me know if it works..

0

精彩评论

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