【问题标题】:codeigniter path error代码点火器路径错误
【发布时间】:2011-12-13 14:28:36
【问题描述】:
我已通过 .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
显示输出
我该如何解决这个问题?
【问题讨论】:
标签:
php
codeigniter
codeigniter-2
codeigniter-url
【解决方案1】:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
这些设置对我有用
【解决方案2】:
您可以将application/config/config.php 中的$uri_protocol 从"AUTO" 更改为"REQUEST_URI"。
【解决方案3】:
你试过了吗?
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
【解决方案4】:
从我的 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>