CodeIgniter Forums
All url's show default controller index function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: All url's show default controller index function (/thread-17746.html)

Pages: 1 2


All url's show default controller index function - El Forum - 04-14-2009

[eluser]jplanet[/eluser]
I've seen others post about this but could not find a solution that worked for me in any of the existing threads. No matter what URL I go to, only the default controller is called, and I get three "Undefined offset" errors, each on a different line of libraries/Router.php.

Here is my htaccess code:

Code:
DirectoryIndex index.php

    RewriteEngine On

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1/ [L]

A possibly relevant line in config.php:

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

Content of routes.php:

Code:
$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";

$route['portfolio/(.+)'] = "welcome/portfolio/$1";
$route['gallery/(.+)'] = "welcome/gallery/$1";
$route['contact'] = "welcome/contact";
$route['sendContact'] = "welcome/sendContact";
$route['(.+)'] = "welcome/content/$1";

The application is running fine on my development machine, and I have several other CI sites doing just fine. I re-downloaded the latest version of CI for this project, figuring I might as well have the latest and greatest, but it's not playing well with the shared Bluehost account (I have other CI sites on that server doing just fine with older versions of CI)...


All url's show default controller index function - El Forum - 04-14-2009

[eluser]TheFuzzy0ne[/eluser]
What lines are the errors reported to be at?


All url's show default controller index function - El Forum - 04-14-2009

[eluser]jplanet[/eluser]
197, 203, and 206.

New thing I just discovered, if I include a trailing slash at the end of the URL, it does not show the warnings. But it still shows only the default controller's index function...


All url's show default controller index function - El Forum - 04-14-2009

[eluser]TheFuzzy0ne[/eluser]
I think you need to remove the trailing slash from the last line of your htaccess file:

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

Otherwise you get a // in your URI, which is no doubt responsible for your error.


All url's show default controller index function - El Forum - 04-14-2009

[eluser]jplanet[/eluser]
Thanks, that got rid of the error message!

Unfortunately, I still have this even more puzzling problem of every URL only calling the default controller index...

I have tried changing

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

to

Code:
$config['index_page'] = "index.php";

But it still does the same thing - Unless I specify index.php in the url, I am seeing the home page no matter what URL I use...


All url's show default controller index function - El Forum - 04-14-2009

[eluser]TheFuzzy0ne[/eluser]
I'd suggest removing the index_page again by setting it to '', and trying the different URI protocols in the config.php file. I'd suggest REQUEST_URI or QUERY_STRING.


All url's show default controller index function - El Forum - 04-14-2009

[eluser]jplanet[/eluser]
You solved it!

Setting the uri protocol to REQUEST_URI in config.php finally solved the problem!

Thank you very, very much. You are a scholar and a gentleman! I would have never thought to look there. I wonder if it is has something to do with the fact that I am using a sub-domain on the production server until the site is ready and the domain is transferred...


All url's show default controller index function - El Forum - 04-14-2009

[eluser]TheFuzzy0ne[/eluser]
URIs seem to be handled differently from platform to platform. Often Windows has a problem with the default, although I've known the odd Linux server to as well.

Glad you got it sorted. Smile


All url's show default controller index function - El Forum - 04-14-2009

[eluser]Thorpe Obazee[/eluser]
Hostgator? :p


All url's show default controller index function - El Forum - 04-14-2009

[eluser]jplanet[/eluser]
It's Bluehost...I have another CI site on there where the protocol is set to the default "auto". I suspect I needed to set it to request_uri because this site is in a sub-directory with a sub-domain. I'll bet that once I xfer the domain name it will work normally when set back to "auto"...(or maybe not - I'm not so familiar with the finer points of DNS settings)...