Allow leading underscore in URL w/o method name |
[eluser]rickyracoon[/eluser]
I am working on an app with a controller named User. I'd like to be able to call the index method of this controller without actually having index appear in the URL. So I construct the URL like this: http://myurl.com/user/username/profile.html Then in my controller I add a _remap to manually send the correct param to the index method: Code: function _remap($method) This works fine except that usernames can start with underscore - so when you try to get to the profile page for a username such as "_monkeyman", codeigniter sends a 404 before it even reaches the _remap of the controller. Here is an example of a URL that fails: http://myurl.com/user/_monkeyman/profile.html Of course, adding index works: http://myurl.com/user/index/_monkeyman/profile.html ...but I want to keep the URL clean. I know Codeigniter thinks I'm trying to access a reserved method because of the leading underscore, any ideas to workaround this? I was thinking routes perhaps but would I be able to keep the URL in the same format? Thanks in advance
[eluser]Kosonome[/eluser]
$route['user/(:any)'] = "user/index/$1"; I guess it's that what you need.
[eluser]rickyracoon[/eluser]
Thanks, that did the trick. Didn't think it would pass along the rest of the URL. Just a note in case anyone else has this issue, I had to remove the remap method to get the routing to work. |
Welcome Guest, Not a member yet? Register Sign In |