无法从 CodeIgniter URL 中删除 index.php [英] Cannot remove index.php from CodeIgniter URL

查看:26
本文介绍了无法从 CodeIgniter URL 中删除 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目录结构是/var/www/CI/文件夹 CI 下的所有文件夹,即应用程序、系统.已经在 CI 下创建了一个 .htaccess 文件.

My directory structure is /var/www/CI/ with all the folders viz., application, system under the folder CI. Have created a .htaccess file under CI.

以下是.htacess中的代码.

Following is the code in .htacess.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index.php|public|images|robots.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

仍然 localhost/CI/blog 给出 404 错误.谁能指导一下这条规则哪里错了?

Still localhost/CI/blog gives 404 error. Can anyone guide as to where this rule is wrong?

推荐答案

请尝试以下操作

首先,请确保您像下面这样设置配置文件..

At first, make sure you set the config file like the following..

$config['index_page'] = '';

还要确保在 httpd.conf 文件中启用了 mod_rewrite,然后,使用以下代码覆盖位于项目根文件夹而不是应用程序文件夹中的 .htaccess 文件.

Also make sure that mod_rewrite is enabled in the httpd.conf file and after that, overwrite your .htaccess file which is located your project root folder not in the application folder with the following code..

RewriteEngine on
RewriteCond $1 !^(index.php|public|.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

这篇关于无法从 CodeIgniter URL 中删除 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆