CodeIgniter Forums
Site only loading the default controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Site only loading the default controller (/thread-38657.html)



Site only loading the default controller - El Forum - 02-15-2011

[eluser]Unknown[/eluser]
Hi guys,

I made a website working on my local server (WAMP Server).
When I put it into a web host, I got a strange error.

This works:
http://www.website.com/dir/project/html/
http://www.website.com/dir/project/html/index.php

Not works:
http://www.website.com/dir/project/html/index.php/
http://www.website.com/dir/project/html/index.php/site
http://www.website.com/dir/project/html/index.php/site/index

They don't even are recognized as classes by CI, the server(not CI) just gives a "Error 404 - page not found"

my base_url is "http://www.website.com/dir/project/html/"



Which are the possibles options for this be happening?


I'm using CI 2.0.0
localhost: Windows 7
webhost: Linux, probably.


Site only loading the default controller - El Forum - 02-15-2011

[eluser]Rok Biderman[/eluser]
I have a similar setup and this is a list of things i would check:
.htaccess (it works without the ? after the index.php on win hosts, but somehow fails otherwise)
there is some fiddling with either making
Code:
$config['uri_protocol'] = "AUTO";
or
Code:
$config['uri_protocol'] = "REQUEST URI";
for the .htaccess to work properly.
config/config.php settings
index.php settings
config/routes.php

If it works on your dev environment, chances are very good the problem is in one of those. Basically on what you just told it has to be somewhere in the routing.


Site only loading the default controller - El Forum - 02-15-2011

[eluser]Unknown[/eluser]
Now, that you mentioned about the "?", I set
Code:
$config['uri_protocol' = 'REQUEST_URI';
and tried "http://www.website.com/dir/project/html/index.php?/site" and I worked fine.

Then I changed index_page
Code:
$config['index_page'] = 'index.php?';

And everything is normal now.

Thanks x 10, Coccodrillo!


Now, can you explain me why that happened?
And if possible, how can I remove that "index.php?" from my url?
I tried changing HTACCESS like this, but nothing has changed:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php?|images|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]



Site only loading the default controller - El Forum - 02-15-2011

[eluser]Rok Biderman[/eluser]
Look, to avoid any confusion, i'll just show you what works for me:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond $1 !^(index\.php|pp|images|public|robots\.txt|css)
    RewriteRule ^(.*)$ ./index.php?/$1 [L]
    
</IfModule>

Code:
$config['index_page'] = '';

and
Code:
$config['uri_protocol']    = "REQUEST_URI";

So, other than a missing dot in .htaccess and taking out the index.php, you should be good to go. If not, first check if you have any custom routes set up and if that is interfering.