codeigniter路径错误

时间:2011-12-13 14:28:37

标签: php codeigniter codeigniter-2 codeigniter-url

我已经通过.htaccess在我的codeigniter中关闭了index.php,并且我在config.php中将索引文件留空了 这是.htaccess代码

RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

我的控制器功能链接为'cuser / authenticate',因此网址看起来像

mydoamin.com/cuser/authenticate

但它显示错误告诉路径未找到 当我编辑上面的网址

mydomain.com/index.php/cuser/authenticate

显示输出

我该如何解决这个问题?

4 个答案:

答案 0 :(得分:1)

您可以将$uri_protocol中的application/config/config.php"AUTO"更改为"REQUEST_URI"

答案 1 :(得分:1)

你试过这个吗?

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

答案 2 :(得分:1)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

这些设置对我有用

答案 3 :(得分:0)

直接复制/粘贴我的codeigniter安装,最新版本..

在config.php中设置以下内容

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

创建一个.htaccess并用它填充:

<IfModule mod_rewrite.c>
RewriteEngine On
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]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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>