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

Rob*_*bin 7 .htaccess codeigniter subdirectory

我正在尝试从我的CI网址中删除index.php,但是按照说明它似乎没有工作.

我在子目录中运行了codeigniter安装.路由配置中有一个名为main的默认控制器,另一个名为'create'的控制器.默认运行正常,但转到/ 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>
Run Code Online (Sandbox Code Playgroud)

Sof*_*fia 26

这应该足够了:

<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>
Run Code Online (Sandbox Code Playgroud)


小智 8

这就是我使用的.我的CodeIgniter也在子目录中运行.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /ci/index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)

  • 我一直在寻找正确的mod_rewrite几个小时,这是最终为我工作的那个!我所要做的就是将`ci /`改为`mysubfolder /` (4认同)

jac*_*7en 6

.htaccess添加:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Run Code Online (Sandbox Code Playgroud)

进入application/config/config.php并清除索引页面配置值:

// Old

$config['index_page'] = "index.php";

// New

$config['index_page'] = "";
Run Code Online (Sandbox Code Playgroud)

解决了我的问题也希望别人...... :)