Codeigniter default routing doesn't work

14,618

The htaccess file should be in the my_base_url directory, and you should include a rewrite base:

Options FollowSymLinks

RewriteEngine on
RewriteBase /my_base_url/
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Share:
14,618
anniebabannie
Author by

anniebabannie

Web Designer and Developer – I specialize in responsive web design for small businesses. My strongest skills are in front-end development but I'm quickly building my server-side skills as well. When I'm not building websites you'll find me traveling, cooking, and drawing.

Updated on June 04, 2022

Comments

  • anniebabannie
    anniebabannie almost 2 years

    In my new CI project, I am getting the following error every time I try to access any URL other than the base url and the base url /index.php. For example, if I'd like to access the "about" page:

    Not Found

    The requested URL /my_base_url/about was not found on this server.

    This is what my routes.php file looks like:

    $route['default_controller'] = "base";
    $route['about'] = "base/about";
    $route['404_override'] = '';
    

    I've triple checked my Base controller and it definitely has an about method (which loads an existing "about" view).

    Here's my .htaccess file:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    And here's a few things I've set in my config.php file:

    $config['base_url'] = 'http://localhost/my_base_url/';
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO';
    

    What am I doing wrong? Any help much appreciated!