【发布时间】:2013-08-18 13:34:41
【问题描述】:
我的 CodeIgniter 项目放在子文件夹中,我想用 .htaccess 隐藏这两个子文件夹。
一切正常,但我当前的 URL 如下所示:
example.com/folder1/folder2/ci_project/class/function/$id
我希望这是:
example.com/class/function/$id
现在,我正在使用这个简单的 .htaccess 代码来从 URL 中删除 index.php:
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
有什么想法吗?
当我在 folder1/folder2/ci_project 内的 htaccess 文件中使用以下代码时,它确实隐藏了子目录,但我收到错误“找不到对象”
RewriteCond %{REQUEST_URI} !^/folder1/folder2/ci_project/
重写规则 ^(.*)$ /folder1/folder2/ci_project/index.php/$1 [L]
【问题讨论】:
-
您可以发布您当前使用的 .htaccess 吗?
-
将 index.php 文件放在根目录外,并将其中的应用程序和系统路径设置为子文件夹。
-
任何反馈将不胜感激。您可以尝试一下当前的答案吗?
标签: .htaccess codeigniter url-rewriting url-routing codeigniter-url