【发布时间】:2013-02-22 16:05:15
【问题描述】:
如何删除 index.php 以便利用 CI 的 URL 技巧?当我删除“index.php”时,它会出现 404 错误或 403,即使控制器上存在必要的类。
这是我目前在根目录上的 .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
config.php 上的其他 CI 规范:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
rewrite_module 已启用。
在 httpd.conf 上:
<Directory />
Options FollowSymLinks
AllowOverride None
Order Allow,Deny
Allow from all
</Directory>
编辑:明确地说,我可以访问我的应用程序的“主页”(http://localhost/projectfolder)。但是,当我访问特定控制器 (http://localhost/projectfolder/admin) 时,它将无法工作。但是当 index.php 在主机和控制器之间时(http://localhost/projectfolder/index.php/admin),它可以工作。我正在寻找解决中间的“index.php”。
【问题讨论】:
-
您不能简单地删除 index.php,因为它会引导 CodeIgniter 应用程序/框架。随意将其移动到另一个目录并将您的 docroot 指向那里。
标签: .htaccess codeigniter