zJorge
zJorge

Reputation: 798

PHP files outside Codeigniter's application folder get 404 error

I recently moved a CodeIgniter site to a new server. Everything is running fine but when attempting to run PHP files on the public folder I get a 404 error message. This is my current structure:

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

If I go example.com/public/sample.html I runs ok. If I instead try example.com/public/simple.php I get a 404 error. I checked .htaccess but it seems ok and it was actually working ok on the previous server.

Just for illustration purposes this is the current .htaccess:

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

I already tried a few solutions from SO but none some got me a 500 error, the rest didn't do anything.

Upvotes: 1

Views: 252

Answers (1)

user4419336
user4419336

Reputation:

On your index.php line 132 if your using codeigniter 3 +

/*
 *---------------------------------------------------------------
 * 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 = '';

Upvotes: 1

Related Questions