2

I'm using the following code in my routes.php to hide the controller name from the URL structure:

$route['(:any)'] = "auth/$1";

It works great, but my problem is this: When I want to access another controller, it seems to treat it as a function of the hidden controller.

So for example. I have

http://mysite.com/controller1/somefunction

which turns into:

http://mysite.com/somefunction

What if I want to access:

http://mysite.com/jsonfunction/anotherfunction/

How can I access the other controller while keeping the other one hidden? I really don't want visitors seeing http://mysite.com/maincontroller/ that's just redundant!

1

1 Answer 1

2

You are going to have to define your routes more specific I am afraid. You can still use:

$route['(:any)'] = "auth/$1";

But it will probably go to the button of your list of routes.

if you want other routes to be added that overrule that one you'll have to place them on top. For example like this:

$route['login'] = "auth/login";
$route['varY'] = "controllerX/varY";
$route['varY/(:any)'] = "controllerX/varY/$1";
$route['foobar'] = "controller/method";
$route['(:any)'] = "auth/$1";

See this document for more info and future reference: http://codeigniter.com/user_guide/general/routing.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.