且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP 的 $_GET 和 URL 重写

更新时间:2023-02-23 12:58:49

是的,这会按预期工作.

How does URL rewriting affect the $_GET parameter for PHP?

Say I have a URL like http://example.com/index.php?p=contact and I use $_GET['p'] to tell index.php to serve the contact page. If I use a rewrite rule that converts the URL to http://example.com/contact, will $_GET['p'] still work as expected?

If it does, could you elaborate on why it works? If not, what strategies could be used to solve the problem so that the page will work both with and without the rewrite?

Yes, that will work as expected.