Welcome Guest, Not a member yet? Register   Sign In
Default controller takes all traffic, even when new controllers / views are defined.
#1

[eluser]FragPacket[/eluser]
Greetings all,

I'm not entirely new to PHP, but only began playing with CI about a week ago. I watched the tutorials and get MVC conceptually. Now I've modified my routes to use a newly created default controller, and that works great.

However, when I create a new controller, "Mylinks", the default controller/view is all I see. That is, when I go to http://www.mysite.com/index.php/mylinks, I see the same thing as if I were to have left off the "/mylinks" part of the URI. New controller looks like this:

Code:
<?php

class Mylinks extends Controller {

    function Mylinks() {
        parent::Controller();    
    }
    
    function index() {
        $this->load->view('mylinks_view');
    }

}


The mylinks_view.php file is very simple -- just an HTML hello world. Am I doing something wrong that's making the default controller respond where it shouldn't?

Also, though I'm not sure it's related, the only other change I made to my CI config was to my config.php file:

Code:
$config['uri_protocol']    = "QUERY_STRING";


Many thanks.
#2

[eluser]FragPacket[/eluser]
Hmmm, well, I switched my config.php file back to the default of:

Code:
$config['uri_protocol']    = "AUTO";

And now, it works as expected. HOWEVER, the reason I switched it away from "AUTO" in the first place now comes back. When I enter the following URI, I get a 404:
Quote:http://www.mysite.com/index.php

Similarly, if I simply enter
Quote:http://www.mysite.com

I also get a 404 page.

When I add a "/" to the end of the URI, things work great. The only thing I could find presenting a fix for this was to switch my 'uri_protocol' configuration to "QUERY_STRING" as noted in the original post. Any suggestions on how to resolve the need for a trailing slash, and still have my new controller methods recognized??


Again, thanks for any help.
#3

[eluser]tamilsweet[/eluser]
I fixed the issue somehow.
* Added the .htaccess rule to remove index.php from uri
* Removed index.php in line => $config[‘index_page’] = “”;
* Changed uri protocol to => $config[‘uri_protocol’] = “REQUEST_URI”;

May be you could try this!
#4

[eluser]FragPacket[/eluser]
Yes!

Works perfectly now. Many thanks.

Heads up to anyone using 1&1 (1and1.com) for hosting... running PHP version 4.4.9.




Theme © iAndrew 2016 - Forum software by © MyBB