How do I convert a PHP query string into a slash-based URL?

前端 未结 3 599
春和景丽
春和景丽 2020-12-10 06:45

I am a pretty skilled programmer, but when it comes to RegEx and rewriting, I am a total n00b. I want to convert a URL from

http://www.example.com/lookup.ph         


        
3条回答
  •  孤城傲影
    2020-12-10 07:16

    Take a look on htaccess rewrite urls! :)

    Here's your example:

    RewriteRule ^lookup/(\d+)/(.*)$ /lookup.php?id=$1&name=$2
    

    When you access lookup/123/my-product/, it'll call the lookup.php?id=123&name=my-product file internally.

提交回复
热议问题