从URL中删除index.php - Codeigniter 2

从URL中删除index.php - Codeigniter 2

我无法从Codeigniter中的URL中删除index.php。我用Codeigniter 1.7创建了一些网站,我使用的.htaccess代码在2中不起作用。

我试过用

<IfModule mod_rewrite.c>RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

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

<IfModule mod_rewrite.c>RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]</IfModule>

我也尝试过没有RewriteBase / in。

我已将$ config ['uri_protocol']更改为REQUEST_URI和QUERY_STRING而没有。

我设置了$ config ['index_page'] =“”;

文件结构是192.168.0.130/(site)/所以它必须返回到服务器的根目录,找不到index.php文件。

我所做的所有控制器都可以通过192.168.0.130/(site)/index.php/testcontroller来实现。

谢谢。

如果之前有人问过这个道歉 - 我已经看过并尝试过我能看到的东西。

编辑:

我还应该补充一点,我将默认文件夹更改为

应用

CI-2.0

的index.php

并将index.php中的路径更改为正确。


慕仙森
浏览 488回答 3
3回答

慕神8447489

尝试使用您发布的第一个代码块,但不要使用/(dex)/index.php(obv替换(站点)与您的站点文件夹命名)。
打开App,查看更多内容
随时随地看视频慕课网APP