Home page routing with $route['(:any)'] |
[eluser]chavansoft[/eluser]
Hello, Any one please help me figure out what should i do for the following I have a Website in localhost i have lots of pages like http://localhost/current/b/index.php/Category http://localhost/current/b/index.php/news http://localhost/current/b/index.php/page/About-Us http://localhost/current/b/index.php/contactus Home is my Default controller Now i have certain products say saloon, carstation, toothbrush and so on... i need this to be like the following url http://localhost/current/b/index.php/saloon http://localhost/current/b/index.php/toothbrush http://localhost/current/b/index.php/ I have tried using this $route['(:any)'] = "home"; in the below one $route['default_controller'] = "home"; $route['scaffolding_trigger'] = ""; $route['news/:any'] = "news/index"; $route['Categories/:any'] = "Categories/index"; $route['product/:any'] = "product/index"; $route['page/:any'] = "page/index"; $route['search/:any'] = "search/index"; $route['(:any)'] = "home"; this does not allow the other pages work. Whatever url i click it goes to home page. Please help me to fix this error Thanks Regards Chavan
[eluser]AoiKage[/eluser]
That's because "$route['(:any)'] = 'home';" will ALWAYS redirect every url to the home controller. And the other ones are wrong, btw. Try with something like this: Code: $route['default_controller'] = "home"; Although that wouldn't make any sense if you don't pass the parameter you insert as a variable... Maybe something like this would make more sense: Code: $route['default_controller'] = "home"; I don't know of a way to strip the various 'product', 'page' etc from the actual URL... if that's what you were trying to do.
[eluser]chavansoft[/eluser]
Thanks for the reply AoiKage But this not the one i asked for. The below works for me http://localhost/current/b/index.php/saloon http://localhost/current/b/index.php/toothbrush the saloon is the query string i pass and its not a controller. Please help me on this
[eluser]AoiKage[/eluser]
Hmmm, okay, now I got it. The problem is I don't even know if it's possibile, and if it is I don't know how to do it. Sorry
[eluser]Phil Sturgeon[/eluser]
There is not much point listing all the controllers that should work normally, just list the special one. Use $route['404_override'] = 'pages'; so all 404 calls go to the pages controller, then use _remap() to show the specific page. AoiKage: Those routes were not wrong. You only need to wrap :any with () if you want to return the segment and use it in the value. ie: $1. If you are just comparing the pattern of the URL and not re-using sements then there is no need to wrap the :any.
[eluser]Phil Sturgeon[/eluser]
http://ellislab.com/codeigniter/user-gui...llers.html
|
Welcome Guest, Not a member yet? Register Sign In |