• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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!

#2
[eluser]Onema[/eluser]
Any updates on this?

#3
[eluser]Unknown[/eluser]
[quote author="Juan Torres" date="1311829607"]Any updates on this?[/quote]

I have no idea where things went wrong, but I downloaded a new copy of CI started from scratch and there were a couple people who took a look at the httpd.conf and other server settings. So We have no way of tracing what went wrong, but the new build I have is working now with the multi-host setup, I have not tried it on 1and1 again as there was no need.

I suspect it was a mod_rewrite issue as my new .htaccess file is much more concise:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|img|js|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

#4
[eluser]Onema[/eluser]
Hey thank you for the reply. After much frustration, I did just what you did and started with a new copy of CI. I added files one by one and tested. Using this method I figure out that in 1and1 the URI is case sensitive (and yes it is a LINUX server!).
So if the class name for the controller is Login, I must access it like this mysite.com/Login/ and not mysite.com/login/. I really don't understand.

I'm still not sure how I'm going to solve this issue...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.