codeigniter returns 404 for everything inside subfolder

In my development environment (Mac OS, Apache, CI app inside a WP folder) my app works fine. Today I deployed it to server (Ubuntu Server, Apache, same CI app inside WP folder) and everything that I try return the 404 page.

This is my app/.htaccess:

Read More
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 is already enabled in this server.

In my config.php I’ve already tried:

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

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

What is wrong here? When I go to http://server/app/index.php I get a 404 message. If I go to http://server/app/controller/action I also get a 404 message.

Related posts

4 comments

  1. Change this

    In your config.php

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

    then in .htaccess( ** this should be place out side of application folder ** )

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

    Read this as well

    1. Controllers
    2. Models
    3. Views
  2. I had same issue. Just change the file permission to 644 to index.php
    When I pull the changes via git. permission change to 664 so change back to 644. Hope this will solve issue.

  3. Try removing the SetEnv . You can set the environment in the index.php file.

    For the base_url, make sure it is the folder level that the index.php page is in.

    /app/ should contain the application folder.

    For the index_page, I would not set this to blank. Put it back to ‘index.php’;

    Try this in your htaccess,

     RewriteEngine on
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
    
     RewriteCond %{HTTP_HOST} ^yoursite.com [nc]
     RewriteRule ^(.*)$ http://www.yoursite.com/$1 [r=301,nc]
     RewriteCond $1 !^(index.php|js|img|css|application|robots.txt)
     RewriteRule ^(.*)$ /index.php/$1 [L]
    

    You may not need to include the application folder in the RewriteCond but try it anyway.

    make sure you default_contoller is set in your /config/routes.php file.

     $route['default_controller'] = "default_controller_here";
    

Comments are closed.