Mod_rewrite and $_GET variables

本秂侑毒 提交于 2019-12-01 19:55:59

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.

It's possible to append it, with the QSA (query string append) flag.

RewriteEngine on
RewriteRule {from-url} {to-url} [L,NC,QSA]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!