我无法从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中的路径更改为正确 .
7 回答
尝试你发布的第一个代码块,但不要使用/index.php而不是/(site)/index.php(用你的站点文件夹命名的obv替换(站点)) .
这对我有用:
创建您的htaccess文件
将$ config ['index_page']设置为空(config.php)
string Set $ config ['uri_protocol'] = 'REQUEST_URI'; (config.php的)
这是我的htaccess文件:
资源:
http://taggedzi.com/articles/display/codeigniter-2-htaccess-and-friendly-urls
只需在根文件夹中将此添加到.htaccess即可
遵循其他人的所有指示并从CodeIgnitor URL documnetation开始,不要忘记 restart the server . 我只是忘记这样做,并继续尝试所有其他解决方案 .
我在这2天了..尝试了一切可能 . 我刚刚出来你需要以下内容:
类型:
并将AllowOverride None更改为AllowOverride All - 这将允许访问.htaccess文件
并且还在Apache上启用mod重写:
希望这会有所帮助,马里奥
您只需在.htacess中添加以下代码即可 .
1)在根文件夹中创建.htaccess文件
2)在Application文件夹中编辑application / config / config.php文件
我希望它对你有用