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

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

问题描述

我想从我的CI网址中删除的index.php,但已经按照说明它似乎并不奏效。

我有一个子目录中的codeigniter安装运行。有一个默认的控制器路由配置称为主设置,另一个控制器称为创造。默认运行正常,但会/创建一个返回324错误说没有数据接收。我的htaccess的是这样的:

 < IfModule mod_rewrite.c>

RewriteEngine叙述上
的RewriteBase /

的RewriteCond%{REQUEST_URI} ^系统。*
重写规则^(。*)$ /index.php?/$1 [L]

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php?/ $ 1 [L]

< / IfModule>

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

解决方案

这应该是足够的:

 < IfModule mod_rewrite.c>
RewriteEngine叙述上

#Checks,查看是否用户正在试图访问一个有效的文件,
#such作为图像或CSS文档,如果这不是它发送的真实
#request的index.php
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
#这个最后一个条件可以访问图像和css文件夹,并且robots.txt文件
的RewriteCond $ l ^(指数\ .PHP |公众|图片|机器人\ .TXT | CSS)!
重写规则^(。*)$的index.php / $ 1 [L]
< / IfModule>
 

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

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>

解决方案

This should be enough:

<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天全站免登陆