去掉CodeIgniter URL中的index.php

这两天在弄一个CodeIgniter URL 去掉index.php

查阅了大量的资料,都没有找到原因。

以下的方法都试过了:

http://www.nowamagic.net/php/php_RemoveIndexInCi.php去掉CodeIgniter URL中的index.php

1. 打开apache的配置文件,conf/httpd.conf :

LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉。

搜索 AllowOverride None(配置文件中有多处),看注释信息,将相关.htaccess的该行信息改为AllowOverride All。
2.将CI中配置文件(system/application/config/config.php)中$config['index_page'] = "index.php";将$config['index_page'] = ""; 。

以及官方的说法

删除 index.php 文件
默认情况下,index.php 文件将被包含在你的 URL 中:

example.com/index.php/news/article/my_article
 
你可以很容易的通过 .htaccess 文件来设置一些简单的规则删除它。下面是一个例子,使用“negative”方法将非指定内容进行重定向:

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

如果你的项目不在根目录请把上面这一句改为:RewriteRule ^(.*)$ index.php/$1 [L]

在上面的例子中,可以实现任何非 index.php、images 和 robots.txt 的 HTTP 请求都被指向 index.php。

不管怎么调试都没有结果,最后查到了APCHE的配置才发现原因所在

原来这里禁权了

<Directory "/var/www/OPEN">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
原文地址:https://www.cnblogs.com/jthb/p/3273105.html