URL ROUTING HELP! :D |
[eluser]Unknown[/eluser]
Hello guys, I just wanted to ask something about URL routing in CI, I have browsed some tutorials in the web and it's quite not helping i Just want to know if theres a chance in order for my scenario to work im still a newbie to CI, im hoping someone can point me to the light.. ok what i really want to achieve,: I have developed a website and i want to access a specific page but it has quite a long URL on it, e.g. http://cebufreeinfo.com/index.php/site_c...nt_main/38 now the client_main method will call the existing client name on the database basing on its ID I want to access that certain client but cutting short the URL.. I want it to look like this, http://cebufreeinfo.com/index.php/(client_name) <-- what ever that is, it should point exactly to what client name it represents. Is there any other approach using the built in URL function of CI I've tried using the routes function but cant seem to make it work. Or Im just too dumb to make it work hehe i just want to know if theres any other solution for this. I appreciate the help thanks in advance
[eluser]Sarfaraz Momin[/eluser]
Hi, I suppose this query has been here quite sometimes and there have been real good answers for this. please refer this post looking for best way to implement unique urls Good Day !!!
[eluser]Unknown[/eluser]
Yes, thanks for giving the heads up, yes i cant still make something out of the discussions well ill just have to read some more to find a specific solution, the solutions given were a lil broad, well thanks anyhow.
[eluser]Michael Ekoka[/eluser]
try this in your config/routes.php Code: $route['([0-9]+)'] = 'site_controller/client_main/$1'; In english: - $route['[0-9]']: Right after the index.php in my url, check for a required digit. - $route['[0-9]+']: That digit is required to successfully match this rule and may be followed by 0 or more digits. In other words there may be 1 or more digits. - $route['([0-9]+)']: Capture all those digits, we may need them later. We will reference them as $1. - 'site_controller/client_main/$1': if you successfully match a route with the previous requirements, redirect it to the site_controller controller, the client_main method and pass the first entry that you captured from the route as a parameter ($1). |
Welcome Guest, Not a member yet? Register Sign In |