CodeIgniter从URL中删除index.php无效

CodeIgniter从URL中删除index.php无效,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,您好,下面是我对从URL中删除index.php所做的更改 替换了$config['index\u page']=“index.php” 到$config['index\u page']=“” 然后替换$config['uri\u protocol']=“AUTO” 通过$config['uri\u protocol']=“REQUEST\u uri” 然后我在.htaccess文件中添加了下面的代码 RewriteEngine on RewriteCond $1 !^(index\.php|r

您好,下面是我对从URL中删除
index.php
所做的更改

替换了
$config['index\u page']=“index.php”

$config['index\u page']=“”

然后替换
$config['uri\u protocol']=“AUTO”

通过
$config['uri\u protocol']=“REQUEST\u uri”

然后我在
.htaccess
文件中添加了下面的代码

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

但这不起作用。有什么问题吗?

您不必编辑index.php,将content.htaccess文件替换为:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

请尝试使用以下代码

RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

我不知道,但我认为你最不需要做的就是在你的Apache上。httpd.conf

改变

AllowOverride None


还可以告诉我.htaccess的位置吗?

将.htaccess文件放在项目文件夹中,如下所示:

htdocs/your_project/.htaccess

请为.htaccess尝试以下新代码:

  <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
  </IfModule>
不要使用:

$config['uri_protocol'] ="AUTO"

希望它能很好地为您工作。

如果它不起作用,请尝试将它放在您项目的所有htaccess文件中:)谢谢,我已经尝试过了,但不适合我。我更新了config.php而不是index.php。。。。你说的“试着把它放在你项目的所有htaccess文件中”是什么意思?在我的项目中,我在应用程序文件夹外和应用程序文件夹内都有htaccess权限。为什么它不起作用?怎么了?规则是有效的,但我犯了愚蠢的错误。我刚刚错过了。(点)in.htaccess文件名:(不适用于我…只有注销时出现此问题检查此url:-
$config['base_url'] = 'http://localhost/your_project_name/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['uri_protocol'] ="AUTO"