How to rewrite url with post title slug?

前端 未结 3 1919
借酒劲吻你
借酒劲吻你 2021-01-07 11:49

Consider a url

www.example.com/paper-ads-details.php?req=43397&rnd=1308546000

I want to change this urls as:

www.exampl         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 12:33

    1. If you want to use .htaccess, you need to write a script to generate the rewrite rules statically, so the .htaccess file contains lines like
      RewriteRule ^jobs-in-chanai.php /paper-ads-details.php?req=43397&rnds=1308546000 [L]

    2. Handle the routing at the start of the request in PHP. Parse (and filter) the url to look up the post based on the slug rather than the req and rnds parameters. Cache the results if needed.

提交回复
热议问题