My current URL is like:
www.hostname.com/get_city/
(this url is already shorten by using routes)
Here get_city
is my method name and now what i exactly want is…
1)remove controller name from url
2)pass selected city value from dropdown and set in URL as a parameter
So,Required url is: www.hostname.com/california
OR www.hostname.com/newjersey
NOTE:I know how to use routes but in such case how to make dynamic URL?!
AND please don’t give me direct reference of ellislab docs because i have already tried those things
3
Answers
For dynamic route in codeigniter:
try like this:
in your routes.php file copy and paste these codes:
so you can , change $string with any string that you want.
then try type new url and see Routes will work fine.
NOTE:.htaccess file must be removing index.php in url
hope this help.
You can try with the method “_remap”.
Check the official documentation for more info about the behavior of the function:
http://www.codeigniter.com/user_guide/general/controllers.html
Regards.
You need to config routes in application/config/routes.php
After existing routes add
But this overwrite all routes and before this route you need to declare all routes for you controllers
and after
DOCS:
http://code-igniter.ru/user_guide/general/routing.html
CI2: URI Routing
CI3: URI Routing