使用 htaccess 删除子目录中的 codeigniter index.php [英] Using htaccess to remove codeigniter index.php in a subdirectory

查看:26
本文介绍了使用 htaccess 删除子目录中的 codeigniter index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的 CI 网址中删除 index.php,但按照说明操作后,它似乎不起作用.

I'm trying to remove the index.php from my CI urls, but having followed the instructions it doesn't seem to be working.

我有一个在子目录中运行的 codeigniter 安装.在路由配置中设置了一个名为 main 的默认控制器,另一个名为create"的控制器.默认运行良好,但转到/create 会返回 324 错误,指出未收到数据.我的 htaccess 看起来像这样:

I have a codeigniter installation running in a subdirectory. There is a default controller set in the routes config called main, and another controller called 'create'. The default runs fine, but going to /create returns a 324 error saying No Data Received. My htaccess looks like this:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

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

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

</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

推荐答案

这应该够了:

<IfModule mod_rewrite.c>
RewriteEngine On

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index.php|public|images|robots.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

这篇关于使用 htaccess 删除子目录中的 codeigniter index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆