Lets say I have a controller ‘standard’ with an action ‘main’.
If I go to http://www.myapp.com/standard/main it will invoke the main action in the standard controller.
Now if I want to change the URL I go into the routes.php and set sth like the following:
$route[‘welcome’] = “standard/main”;
Now I can visit http://www.myapp.com/welcome and it will invoke the same action.
However it is still possible to visit http://www.myapp.com/standard/main. I now have two routes which lead to the same controller action.
Is this the usual way or should I somehow disable the now unwanted http://www.myapp.com/standard/main route? If so, how would I do that?
Thanks in advance.
That is completely for you to decide the default behavior. If you decide to disable the original url, you can write something like
Or any custom location, it depends on your project and how you wish it should look like, for example you can ‘block’ any method from being accessed directly:
But bear in mind, if you route like you did
$route['welcome'] = "standard/main";, then you should always remember that the function$this->uri->segment(n)will show different values, for example if I will go to url yoursite.com/welcome/123, the value of$this->uri->segment(2)will be123, but if I visit the original URL yoursite.com/standard/main/123, it’s value will change tomain.Bear that in mind and decide for yourself!