default_controller problem |
[eluser]Santiag0[/eluser]
Hi! I'm starting with CI. I have a little problem when I try to set the router of the default_controller. Code: $route['default_controller'] = 'welcome'; //It's OK eg. fotolog.com/jhon so i need a friendly URI, like myweb.com/user_loco and the user see his profile. Thanks a lot!!
[eluser]Doosje[/eluser]
I think you mean Code: $route['default_controller'] = 'welcome'; http://localhost/welcome/username and then loads controller users, function name, and passes the $1 to the function. (or you can work with the this->uri->segment or somethign similar.
[eluser]Santiag0[/eluser]
Really thanks, you are great!! I try your code this night, when i arrive to home. Thanks again ![]()
[eluser]Santiag0[/eluser]
Sorry, doesn't for my. Do you think in another solution? Thanks!
[eluser]Doosje[/eluser]
i dont; think it's my code .. but youre regex !!! Code: $route['welcome/([a-z0-9])'] = 'users/name/$1'; Code: $route['welcome/([a-z0-9]+)'] = 'users/name/$1';
[eluser]Santiag0[/eluser]
Sorry, but didn't work too. I try with some variants and always show error 404. I think that is it because always try to load a class, if I put: http://localhost/ Show welcome If i put http://localhost/usernameX Try to load a class, so display "404 Page Not Found" I think that the solution its put a code to modify all urls, in this way: If ($this->uri->segment[0]) != 'go') { $this->uri->segment[2] = $this->uri->segment[0] $this->uri->segment[0] = 'users'; $this->uri->segment[1] = 'name'; } else //this->uri->segment[0] is equal to go, so the second is the correct class, the third the method, etc... array_shift($this->uri->segment); //Shift an element off the beginning of array When i can put this code? Thanks a lot for your help, Big Student!!
[eluser]Tom Glover[/eluser]
Have a look here: http://ellislab.com/codeigniter/user-gui...uting.html
[eluser]Santiag0[/eluser]
Thanks, i read that a lot of times but i dont found the solution. If you can help me in some way, i apreciate it. Thanks again, Santiago |
Welcome Guest, Not a member yet? Register Sign In |