php - codeigniter 对子文件夹内的所有内容返回 404

标签 php wordpress .htaccess codeigniter mod-rewrite

在我的开发环境(Mac OS、Apache、WP 文件夹内的 CI 应用程序)中,我的应用程序运行良好。今天,我将其部署到服务器(Ubuntu Server、Apache、WP 文件夹内的相同 CI 应用程序),我尝试的所有内容都返回 404 页面。

这是我的应用程序/.htaccess:

SetEnv CI_ENV development

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

mod_rewrite 已在此服务器中启用。

在我的 config.php 中我已经尝试过:

 $config['base_url'] = 'http://server/app/';

 // problem in both situations
 $config['index_page'] = 'index.php';
 $config['index_page'] = '';

这里出了什么问题?当我去 http://server/app/index.php我收到 404 消息。如果我去http://server/app/controller/action我还收到了 404 消息。

最佳答案

改变这个

在你的config.php

  1. $config['base_url'] = '';
  2. $config['index_page'] = '';
  3. $config['uri_protocol'] = 'AUTO';

然后在.htaccess中(**这应该放在应用程序文件夹的外面**)

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

也请阅读此内容

  1. Controllers
  2. Models
  3. Views

关于php - codeigniter 对子文件夹内的所有内容返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30850876/

相关文章:

php - ZF路由问题

javascript - 2 个表单,只有一个提交按钮 $_POST 方法

wordpress:previous_post_link()/next_post_link() 占位符

javascript - jQuery 在 ajax 调用后更新 li 类属性 href

php - 使用 .htaccess 重定向/投票到/vote.php?vote=1

php - 使用 AJAX 将表单值提交到数据库

php - 循环出 WordPress 菜单项和子菜单项

regex - 如何使用 htaccess 将 %20 或空白自动重定向到 + 或 - ?

.htaccess - 将带有参数的 URL 重定向到具有相同参数的其他域

php - 显示偶数和奇数 SQL 结果 (PHP)