Codeigniter的应用程序文件夹外的PHP文件出现404错误

时间:2017-03-30 04:17:11

标签: php .htaccess codeigniter

我最近将CodeIgniter站点移动到了新服务器。一切运行正常但是当试图在公共文件夹上运行PHP文件时,我收到404错误消息。这是我目前的结构:

public_html/ 
 |–– application/ 
 |–– public/
 |      |-sample.html
 |      |-simple.php
 |       
 |–– system/ 
 |–– uploads/ 
 |-- .htaccess
 |–– index.php 

如果我去example.com/public/sample.html我运行正常。如果我改为example.com/public/simple.php,我会收到404错误。我检查了.htaccess但似乎没问题,它在以前的服务器上实际上工作正常。

仅用于说明目的,这是当前的.htaccess:

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

我已经尝试了一些来自SO的解决方案,但是没有人遇到500错误,其余的都没有做任何事情。

1 个答案:

答案 0 :(得分:1)

如果您使用codeigniter 3 +

,请在index.php第132行
/*
 *---------------------------------------------------------------
 * VIEW DIRECTORY NAME
 *---------------------------------------------------------------
 *
 * If you want to move the view directory out of the application
 * directory, set the path to it here. The directory can be renamed
 * and relocated anywhere on your server. If blank, it will default
 * to the standard location inside your application directory.
 * If you do move this, use an absolute (full) server path.
 *
 * NO TRAILING SLASH!
 */
    $view_folder = '';