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