Welcome Guest, Not a member yet? Register   Sign In
URI + Routing Issues
#1

[eluser]Unknown[/eluser]
I have a fully working site on CI2 running on MAMP. I have since uploaded it to two different hosts, both have the same issue.

The homepage, styles, and scripts load fine, but any other page does not work.

The .htaccess
Code:
<IfModule mod_rewrite.c>
  Options +FollowSymLinks -Indexes
  RewriteEngine on
  RewriteBase /codeigniter
  #remove access to system folder
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php/$1 [L]

  #check if user is accessing a file or folder that already exists
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php and everything works as normal.
  ErrorDocument 404 /index.php
</IfModule>


The application/config/config.php file:
Code:
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url']    = $root;

$config['index_page'] = '';

// I have already tried all the options here
$config['uri_protocol'] = "REQUEST_URI";


...So I have turned the logs on and here's what I get for the homepage where all is fine:

Quote:DEBUG - 2011-06-10 21:03:18 --&gt; Config Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Hooks Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Utf8 Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; UTF-8 Support Enabled
DEBUG - 2011-06-10 21:03:18 --&gt; URI Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Router Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; No URI present. Default controller set.
DEBUG - 2011-06-10 21:03:18 --&gt; Output Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Security Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Input Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2011-06-10 21:03:18 --&gt; Language Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Loader Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; Helper loaded: url_helper
DEBUG - 2011-06-10 21:03:18 --&gt; Helper loaded: assets_helper
DEBUG - 2011-06-10 21:03:18 --&gt; Controller Class Initialized
DEBUG - 2011-06-10 21:03:18 --&gt; File loaded: /path/to/the_view.php
DEBUG - 2011-06-10 21:03:18 --&gt; Final output sent to browser
DEBUG - 2011-06-10 21:03:18 --&gt; Total execution time: 0.0251

And, then right below where I requested a URI defined in routes.php:


Quote:DEBUG - 2011-06-10 21:11:33 --&gt; Config Class Initialized
DEBUG - 2011-06-10 21:11:33 --&gt; Hooks Class Initialized
DEBUG - 2011-06-10 21:11:33 --&gt; Utf8 Class Initialized
DEBUG - 2011-06-10 21:11:33 --&gt; UTF-8 Support Enabled
DEBUG - 2011-06-10 21:11:33 --&gt; URI Class Initialized
DEBUG - 2011-06-10 21:11:33 --&gt; Router Class Initialized
ERROR - 2011-06-10 21:11:33 --&gt; 404 Page Not Found --&gt; Ctrl_name

...and yes the controller - "404 Page Not Found --&gt; Ctrl_name" is the correct one defined in the routes.php for the URI entered.

Just to re-iterate, everything works fine, but when put on a different host only the home page with no URI works. I have tried this on two different hosts, (one of them is at work, another at 1and1) I have tried tons of different configurations with the .htaccess file and the config file, but I can't seem to get it working. I always get the CodeIgniter custom 404 page for anything with a URI. (well with some configurations of the $config['uri_protocol'] and Rewrite rules I would get the server default 404, but where I am now with the code above I get the CI 404 error).

Any help would be greatly appreciated. Thanks!


Messages In This Thread
URI + Routing Issues - by El Forum - 06-10-2011, 07:28 PM
URI + Routing Issues - by El Forum - 07-27-2011, 06:06 PM
URI + Routing Issues - by El Forum - 07-27-2011, 09:59 PM
URI + Routing Issues - by El Forum - 07-28-2011, 12:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB