Remove "index.php" from Codeigniter .htacceess


Remove "index.php" from Codeigniter .htacceess

我已经在Codeigniter工作了几天了&一切都很顺利,接受我这辈子都不能去掉url中的index.php(从localhost/index.php/controller到localhost/controller)。

我使用CIs默认的index.php.

在apache中是允许重写的

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

(虽然我已经尝试了URI的其他四种设置)

。Htaccess是这样的

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond $1 !^(index'.php|resources|robots'.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
  <Files "index.php">
    AcceptPathInfo On
  </Files>
</IfModule>
<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

我试过答案了在这里和

帮助将是美妙的

谢谢

注:我在子域工作,如果这很重要。

将以下规则放入。htaccess文件,

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

如果上面的行不能工作,那么你需要打开你的CI配置文件application/config/config.php

在其中找到以下行

$config['index_page'] = 'index.php';

改为:

$config['index_page'] = '';

如果这不起作用,那么尝试在config:

中将uri_protocol更改为auto:
$config['uri_protocol'] = 'AUTO';

在。htaccess中这可能是一个问题
RewriteCond $1 !^(indew'.php|resources|robots'.txt)
如何在Apache 2.2中启用mod_rewrite
或者对于rewriterrule行,尝试将其更改为

RewriteRule ^(.*)$ /index.php/$1 [L]

(index.php前的/)