$_GET and URL Rewriting for PHP

后端 未结 7 2135
旧时难觅i
旧时难觅i 2020-12-13 22:09

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 $_G

7条回答
  •  悲哀的现实
    2020-12-13 22:44

    When rewriting an URL this is done by mod_rewrite -- the page retrieved in the end is still the "old" one, i.e. index.php?p=contact. In other words, the browser retrieves /contact. mod_rewrite then rewrites it to index.php?p=contact. The script, due to this, doesn't know that any rewriting happened -- it still gets called its "usual" way. Therefore such a rewrite will work. You might want to think of it as a rewriting proxy that requests a different page than the one the originating browser requested.

提交回复
热议问题