.htaccess - 使用 htaccess 删除子目录中的 codeigniter index.php

标签 .htaccess codeigniter subdirectory

我试图从我的 CI url 中删除 index.php,但按照说明它似乎不起作用。

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

<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 - 使用 htaccess 删除子目录中的 codeigniter index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6765883/

相关文章:

php - Youtube API如何使用GetUserUpload方法PHP获取所有视频ID

function - 附加子目录时,Powershell函数返回双路径

node.js - 如何修复路由以在 node.js 的子文件夹中查找 View

javascript - 将特定虚拟网址重定向到index.html

php - .htaccess 在 ubuntu 服务器上无法正常工作

.htaccess - Mod重写file.php?串起来

regex - mod_rewrite RewriteCond - 仅域部分需要 Ncflags吗?还有一些

php - 在 Codeigniter 的 View / Controller 中使用模型

C++ : loop on all files of a folder (and its subdfolders) : simplest solution?

php - Codeigniter,域到网站的某个区域