douzinei6926 2010-01-24 14:10
浏览 43
已采纳

htaccess mod_rewrite: - products.php?cat = 1 to / myfolder1 / myproduct1 /

I've got a url type:- http://www.example.com/products.php?cat=1 which I am able to rewrite to:- http://www.example.com/myproduct1 using the following .htaccess rule:- RewriteRule ^myproduct1$ products.php?cat=1.

What rule would I need to enter if I wanted to rewrite to:- http://www.example.com/myfolder1/myproduct1/?

  • 写回答

2条回答 默认 最新

  • duan0513 2010-01-24 14:17
    关注

    For any arbitrary path segments a and b in /a/b/, you can use this:

    RewriteRule ^([^/]+)/([^/]+)/$ products.php?segment1=$1&segment2=$2
    

    Edit    In response to your comment: Just put good/boy in your pattern:

    RewriteRule ^good/boy$ products.php?cat=1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?