7
votes

I have 3 servers, a localhost apache server, a testing remote server and the production live server.

I have the same installation of codeigniter and site set-up on all 3 of them and on the localhost and testing servers routing without 'index.php' works 100%. On the Production server however, no matter what the URL says only the homepage (via the default controller) will be shown, it seems all routing rules are being ignored except the default one.

If however index.php is added in the URL then it will work like it supposed to.

For instance if the URL on the production site is: 'www.mysite.com/information' then the content that loads is form the default controller.

But when the URL on the production site is: 'www.mysite.com/index.php/information' then the content that loads is from the 'information' controller.

This is the contents of my htacess file: http://pastebin.com/cDaZVJ8A

This is my routes config file: http://pastebin.com/7Ewc2bwN

My $config['index_page'] is set to nothing.

I really dont know why its not working, the same setup on all servers in term of codeigniter itself, and mod_rewrite IS working on the production server.

I don't know what to do, how can I find-out what's wrong?

4
Did you check whether routes.php exists in application/config/production directory? If the file exists it will overrides the one in application/config directory.Stanley
@Stanley, it does exist on the production server in the correct place.Nicekiwi
@Stanley, wait what? there are no folders within the config directory?Nicekiwi
Different configuration file could be loaded depending on the ENVIRONMENT constants defined in index.php. I am just suspecting that the actual routes config loaded in production is not the one you are looking at. About EnvironmentsStanley
@Stanley, wow that is a really awesome feature. But there are no subdirectories in my config folder and I have not setup different config for different environments.Nicekiwi

4 Answers

8
votes

This is quite a common problem that often occurs when people move a codeigniter install from one environment to another. I have no idea why it occurs, could be a difference in server OS or apache settings, but the solution is often to add a question mark ? to the RewriteRule for the index.php in your .htaccess file.

Old:

RewriteRule ^(.*)$ index.php/$1 [L]

New:

RewriteRule ^(.*)$ index.php?/$1 [L]
2
votes

Check your Apache virtual host configuration and verify that you have AllowOverride All in your directory definition.

1
votes
  1. Maybe something is wrong with your .htaccess file?

    Once I had problem when I moved application to production server, because RewriteBase was set to some directory on development server.

    On my production server application was in web root directory, so RewriteBase should be /, and i had /something there.

  2. Once i had silly problem with upper/lowercases, when i moved site from development server (windows) to production (linux).

0
votes

I had the same problem. I was using function to convert article names to URL's (slugify).

On localhost and on server this function returned slightly different urls.