Mod_rewrite and $_GET variables

前端 未结 2 598
无人共我
无人共我 2021-01-19 04:48

If I am mod_rewriting a URL from:

http://www.mysite.com/blog/this-is-my-title/1/

to

http://www.mysite.com/blog.php?title=this-is-my-title&id=1

2条回答
  •  时光说笑
    2021-01-19 05:50

    You can add QSA to the RewriteRule flags:

    RewriteRule page_([0-9]+)\.html page.php?id=$1 [QSA]
    

    Will redirect page_1.html?a=2 to page.php?id=1&a=2

    However, be careful because requesting page_1.html?id=2 will redirect to page.php?id=1&id=2, and (in PHP), $_GET['id'] will be 2.

提交回复
热议问题