PHP_SELF vs PATH_INFO vs SCRIPT_NAME vs REQUEST_URI
我正在用CodeIgniter构建一个PHP应用程序。CodeIgniter 将所有请求发送到主控制器:。但是,我不喜欢在URI中看到。例如,将路由到 。我需要一种可靠的方法让脚本知道它的地址是什么,这样它就会知道如何处理导航。我已经按照CodeIgniter文档使用了。index.php
index.php
http://www.example.com/faq/whatever
http://www.example.com/index.php/faq/whatever
mod_rewrite
规则如下:
RewriteEngine on
RewriteCond $1 !^(images|inc|favicon\.ico|index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
通常,我会检查,但在这种情况下,它总是。我可以从 ,等处获取它,但我试图决定哪个最可靠。有谁知道(或知道在哪里可以找到)和 之间的真正区别?感谢您的帮助!php_self
index.php
REQUEST_URI
PATH_INFO
PHP_SELF
PATH_INFO
SCRIPT_NAME
REQUEST_URI
注意:我不得不添加空格,因为SO看到了下划线,并且由于某种原因将其设置为斜体。
更新:修复了空格。