使用htaccess的删除codeigniter的index.php在一个子目录在一、个子、目录、codeigniter

2023-09-02 00:24:42 作者:顾人西辞

我想从我的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>
 
查找指定字符 Excel常用查找函数

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>