![]() |
regex help - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: regex help (/showthread.php?tid=12643) Pages:
1
2
|
regex help - El Forum - 10-26-2008 [eluser]Thorpe Obazee[/eluser] How can I use the CI routing to figure out this. Every URL with the controller, user, that does not have the method, 'register' and 'login' should be routed to 'user/view/$1 $route['user/[^register]'] = "user/view/$1"; I currently have this and I know this doesn't work. It produces a 404 when I go to 'user/username' but is ok when I go to 'user/register'. regex help - El Forum - 10-26-2008 [eluser]dmiden[/eluser] working on a fix sec regex help - El Forum - 10-26-2008 [eluser]dmiden[/eluser] Code: $route['user/(?:(?!register|login).)*'] = "user/view/$1"; If you want it to still use the old you can use $this->uri->rsegments(n); regex help - El Forum - 10-26-2008 [eluser]Thorpe Obazee[/eluser] User is my controller. Not the view. Can you explain how you got to that regex? regex help - El Forum - 10-26-2008 [eluser]dmiden[/eluser] I meant view as in the method in your controller ![]() F.ex. if you would like to get the $1 from user/view/$1 you would normally use $this->uri->segment(3) but since you've routed the url it's now, $this->uri->segment(2) example: http://localhost/user/chamyto as chamyto is the 2nd param If you instead want the routed URI segment you could use $this->uri->rsegment(n) then $this->uri->rsegment(3) would be chamyto Use http://www.regular-expressions.info/refadv.html for advanced reference in reg exp ![]() regex help - El Forum - 10-26-2008 [eluser]Thorpe Obazee[/eluser] ![]() but $this->uri->rsegment(3) isn't giving me anything... just blank. regex help - El Forum - 10-26-2008 [eluser]dmiden[/eluser] Try checking the data using print_r($this->uri->rsegment_array()); regex help - El Forum - 10-26-2008 [eluser]Thorpe Obazee[/eluser] although the $this->uri-segment(2) is working. will check. regex help - El Forum - 10-26-2008 [eluser]Thorpe Obazee[/eluser] Array ( [1] => user [2] => view [3] => ) ok nothing is available... regex help - El Forum - 10-26-2008 [eluser]dmiden[/eluser] Odd, well just use $this->uri->segment then ![]() |