php - Codeigniter 3 删除 index.php 问题

标签 php apache .htaccess codeigniter mod-rewrite

我有一个在 codeigniter 2.1.4 中为客户开发的小项目,现在他坚持要迁移到 codeigniter 3 DEV 版本。我知道这不是一个好主意,但是...... 我的问题是我无法从 url 中删除 index.php。

这是我的 .htaccess 文件:

  Options +FollowSymLinks
  RewriteEngine on

  # Send request via index.php
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]

我已经从 config.php 文件中删除了 index.php
运气不好
我重新安装了 LAMP 服务器(我在 Ubuntu 12.04' 上),重新配置
我的本地服务器上有其他项目是在 Codeigniter 2.1.4 和 Laravel 4 上开发的,它们工作得很好,但这个是杀了我。
谢谢!

最佳答案

我是这样做的:

在项目的根文件夹中创建了 .htaccess,内容如下:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|css|js|images|robots\.txt)
RewriteRule ^(.*)$ index.php?$1 [L]

然后,我在 config.php 中修改了这一行。

来自:

$config['url_suffix'] = 'index.php';

收件人:

$config['url_suffix'] = '';

关于php - Codeigniter 3 删除 index.php 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20169545/

相关文章:

java - Stomp 的 MessageMap 格式是不是完全不能用了?

javascript - 为 ipad mini 调试 wordpress

php - 带有 PHP SDK 的 AWS MediaLive 不返回 channel 列表

apache - htaccess - 从 url 中删除 .php 扩展名

apache - .htaccess 为父级而不是子级重定向?

php - $results 上的 fetch() 返回 bool 值

java - 如何从后端(Tomcat)调度 Java Web 应用程序进程?

apache - 用 RewriteLock 理解 Apache RewriteMap

python - Apache 进程空闲并占用内存

php - CSS 文件未使用 mod_rewrite 加载