【发布时间】:2020-01-25 09:50:49
【问题描述】:
我需要将 $config['uri_protocol'] 从 AUTO 更改为 PATH_INFO(以允许 url 参数)
我的问题:当我设置$config['uri_protocol']="PATH_INFO"; 时,常规网址停止运行,无论我点击哪个网站页面网址,我都会获得主页。
print_r ($_SERVER) 显示我添加的 url 参数仅出现在 REQUEST_URI 中,而不出现在任何其他 $_SERVER 部分中。
我的 htaccess 是standard one
<IfModule mod_rewrite.c>
RewriteEngine On
# This is different between local host and production server!!!
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
更新:
我变了
RewriteRule ^(.*)$ index.php?/$1 [L]
到
RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 允许 url 参数通过。现在 url 参数也出现在
$_SERVER
REDIRECT_QUERY_STRING, QUERY_STRING AND REQUEST_URI
.
问题:我使用上述所有选项尝试了 $config['uri_protocol'],但每当我添加 URL 参数时,CI 仍然会给出错误 404。
注意:我在 2 台服务器上尝试了上述方法。其中一个是 centos5/Apache2/Plesk VPS,另一个是 xampp/Vista。
【问题讨论】:
标签: .htaccess codeigniter