Codeigniter mod_rewrite用于根目录和子目录

时间:2013-06-05 08:47:24

标签: codeigniter .htaccess mod-rewrite

我有:

root/.htaccess

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [QSA,L]

它完美地将所有请求(文件和文件夹除外)发送到index.php。我也需要它来处理我的子文件夹。
我在子文件夹root/demos/project中有.htaccess包含:

RewriteOptions inherit

但不起作用。

我在root / .htaccess

中尝试这个
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
RewriteRule ^demos/project/(.*)$ demos/project/index.php/$1 [QSA,L]

不起作用。

这样:

RewriteRule ^demos/project/(.*)$ demos/project/index.php/$1 [QSA,L]
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

获取内部服务器错误'missconfiguration'

还有很多方法,但是我试过的一切,我只是得到了这些:501(默认来自服务器)和404(来自ci的root);

我在rootdemos/project中都使用了codeigniter,只想从两者中“隐藏”index.php,如何正确执行此操作?

感谢。

1 个答案:

答案 0 :(得分:0)

RewriteEngine on
RewriteRule ^(.*)$ /demo/project/index.php?/$1 [L]

有效吗?

您也可以在演示/项目文件夹中放置另一个.htaccess。

编辑:

试试这个:

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

EDIT2:

如果您找到404未找到的页面,只需从以下内容更改root / application / config / config.php中的config.php:

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

为:

$config['index_page'] = "";
相关问题