Codeigniter $ config ['uri_protocol']问题 [英] Codeigniter $config['uri_protocol'] problem
问题描述
我需要将 $ config ['uri_protocol']
从AUTO更改为PATH_INFO(允许网址参数)
我的问题:当我设置 $ config ['uri_protocol'] =PATH_INFO;
常规网址停止运行,我获得主页,无论哪个网站页面URL点击
print_r($ _SERVER)表示我添加的网址参数只显示在REQUEST_URI中,不在任何其他$ _SERVER部分中。
我的htaccess是标准版
< IfModule mod_rewrite.c>
RewriteEngine On
#这是本地主机和生产服务器之间的不同!
RewriteBase /
#删除用户对系统文件夹的访问权限。
#另外,这将允许您创建一个System.php控制器,
#previously这是不可能的。
#'system'可以替换,如果你已经重命名您的系统文件夹。
RewriteCond%{REQUEST_URI} ^ system。*
RewriteRule ^(。*)$ /index.php?/$1 [L]
#检查用户是否尝试访问一个有效的文件
#s如一个图像或CSS文档,如果这不是真的,它发送
#request到index.php
RewriteCond%{REQUEST_FILENAME}! - f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php?/ $ 1 [L]
< / IfModule>
< IfModule!mod_rewrite.c>
#如果我们没有安装mod_rewrite,所有404的
#都可以发送到index.php,一切正常。
#提交者:ElliotHaughin
ErrorDocument 404 /index.php
< / IfModule>
更新:
p>
RewriteRule ^(。*)$ index.php?/ $ 1 [L]
至
RewriteRule ^(。*)$ index.php?/ $ 1 [QSA,L]
允许url params传递。现在网址列也出现在
$ _SERVER
REDIRECT_QUERY_STRING,QUERY_STRING AND REQUEST_URI
。
问题:我试过$ config ['uri_protocol ']与所有上面的选项,但仍然CI给我的错误404每当我添加网址参数。
注意:我尝试以上2台服务器。其中一个是centos5 / Apache2 / Plesk VPS,另一个是xampp / Vista。
解决方案I need to change
$config['uri_protocol']
from AUTO to PATH_INFO (to allow url parameters)My problem: when I set
$config['uri_protocol']="PATH_INFO";
the regular urls stop functioning and I get the homepage no matter which site page URL I click.print_r ($_SERVER) shows that url parameters I add appear only in REQUEST_URI an not in any other $_SERVER part.
my htaccess is the 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>
UPDATE:
I changed
RewriteRule ^(.*)$ index.php?/$1 [L]
to
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
to allow url params to pass. Now url params appear also in$_SERVER REDIRECT_QUERY_STRING, QUERY_STRING AND REQUEST_URI
.
The problem: I tried $config[‘uri_protocol’] with all the above options but still CI gives error 404 whenever I add URL parameters.
Note: I tried the above on 2 servers. One of them is centos5/Apache2/Plesk VPS and another one is on xampp/Vista.
解决方案how to remove url parameters in htaccess
这篇关于Codeigniter $ config ['uri_protocol']问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!