06-10-2011, 07:28 PM
[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
The application/config/config.php file:
...So I have turned the logs on and here's what I get for the homepage where all is fine:
And, then right below where I requested a URI defined in routes.php:
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!
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 --> Config Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Hooks Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Utf8 Class Initialized
DEBUG - 2011-06-10 21:03:18 --> UTF-8 Support Enabled
DEBUG - 2011-06-10 21:03:18 --> URI Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Router Class Initialized
DEBUG - 2011-06-10 21:03:18 --> No URI present. Default controller set.
DEBUG - 2011-06-10 21:03:18 --> Output Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Security Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Input Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Global POST and COOKIE data sanitized
DEBUG - 2011-06-10 21:03:18 --> Language Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Loader Class Initialized
DEBUG - 2011-06-10 21:03:18 --> Helper loaded: url_helper
DEBUG - 2011-06-10 21:03:18 --> Helper loaded: assets_helper
DEBUG - 2011-06-10 21:03:18 --> Controller Class Initialized
DEBUG - 2011-06-10 21:03:18 --> File loaded: /path/to/the_view.php
DEBUG - 2011-06-10 21:03:18 --> Final output sent to browser
DEBUG - 2011-06-10 21:03:18 --> 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 --> Config Class Initialized
DEBUG - 2011-06-10 21:11:33 --> Hooks Class Initialized
DEBUG - 2011-06-10 21:11:33 --> Utf8 Class Initialized
DEBUG - 2011-06-10 21:11:33 --> UTF-8 Support Enabled
DEBUG - 2011-06-10 21:11:33 --> URI Class Initialized
DEBUG - 2011-06-10 21:11:33 --> Router Class Initialized
ERROR - 2011-06-10 21:11:33 --> 404 Page Not Found --> Ctrl_name
...and yes the controller - "404 Page Not Found --> 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!