在我的开发环境(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
$config['base_url'] = '';
$config['index_page'] = '';
$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>
也请阅读此内容
关于php - codeigniter 对子文件夹内的所有内容返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30850876/