开发者

mod_rewrite - need help with friendly URL

开发者 https://www.devze.com 2022-12-15 17:54 出处:网络
How would you mod_rewrite a url to go from directory.php?id=4 to directory/category/city/name/4/ I took a stab in the dark with

How would you mod_rewrite a url to go from

directory.php?id=4 to directory/category/city/name/4/

I took a stab in the dark with

RewriteRule ^directory/*/*/*/([^/\.]+)/?$ directory.php?&id=$4

But not 开发者_高级运维working obviously. Any help is greatly appreciated


How about:

RewriteRule ^directory\.php/.*/.*/.*/(.*)/$ directory.php?id=$1

The parentheses do the capture, and since you are only doing one capture, then the can use '$1' in the target.

Edit: I'm assuming that you want the URL without the query string to redirect to the one with the query string (not 100% clear in your question, sounds like it is the other way around)

0

精彩评论

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