Welcome Guest, Not a member yet? Register   Sign In
URI Routing - only allow custom route?
#1

I have some routing setup e.g. I use an `auth` controller for login/logout stuff etc. and I am routing the methods to nicer URLs to remove the `auth` wording, so `auth/logout` simply becomes `logout`.

However, you can still access `auth/logout` if you know the URL exists.

Is there a way to force the custom routes to be the only way to access that particular Controller and Method?
Reply
#2

There's nothing built into the system currently to handle that. However, you can use a regular expression to catch all routes not defined and route them to a junk page that will error out. Not ideal, but will work. Something like:

Code:
$route['(.+)'] = 'something';

Just make sure that's the very last route in your system.
Reply
#3

Quote:However, you can still access `auth/logout` if you know the URL exists.

* You can  put something in the constructor of the logout controller to catch this,
and redirect them before any of the methods can be called. Or you can do something similar in the index method if its easier.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB