Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] weird issue with controller redirecting itself to /controller/?/controller
#1

[eluser]Flemming[/eluser]
Hi gang. I have this weird issue with ONE of my controllers. When I call it directly from the browser by typing into the address bar like this:

mysite.com/menus

it works fine.

BUT - if I go to that page via a link in another page (href='/menus') it immediately redirects itself to /mysite.com/menus/?/menus and then gives me a 404 error.

It's only happening with this one controller. All the others are fine. I'm not doing anything unusual in this particular controller and in fact I've even tried totally stripping it down to :

Code:
<?php

class Menus extends Controller {

    function __construct()
    {
        parent::Controller();
    }

    function index()
    {
       echo 'hello world';
    }
}

and still I have the same problem.

So I put the controller on another of my CI sites and it worked absolutely fine!

It must be something to do with my config somewhere but I can't for the life of me figure it out. Has anyone else ever come across this? I'm stumped! :long:
#2

[eluser]überfuzz[/eluser]
Why are you linking with a url looking like that..? href=’/menus’ Be on the safe side and add base_url(). That way you'll send an absolute url to the browser.
#3

[eluser]Flemming[/eluser]
Thanks for the suggestion uberfuzz but that made no difference (I always do my urls like that without any problems) ... in the end it was my own stupid fault for having a directory in the root named 'menus' - the same as my controller!
#4

[eluser]überfuzz[/eluser]
Ok i see, but using the base_url gives you the same flexibility. +The urls looks a bit more like real urls. ;-)




Theme © iAndrew 2016 - Forum software by © MyBB