CodeIgniter Forums
1 Level URL Question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: 1 Level URL Question (/showthread.php?tid=40138)



1 Level URL Question - El Forum - 03-30-2011

[eluser]Unknown[/eluser]
Hi Guys,

I am still fresh with CodeIgniter, I have been wondering and searching about the urls and still could not find the answer.

Would it be possible to have every urls in 1 level. such as

so instead of:

http://www.test.com/category
- http://www.test.com/category/bikes
- http://www.test.com/category/cars

http://www.test.com/brand
- http://www.test.com/brand/toyota
- http://www.test.com/brand/honda

I will have:

http://www.test.com/category
- http://www.test.com/bikes
- http://www.test.com/cars

http://www.test.com/brand
- http://www.test.com/toyota
- http://www.test.com/honda

Thank you. Smile


1 Level URL Question - El Forum - 03-31-2011

[eluser]WanWizard[/eluser]
You can do that with routes, but it would require an awful lot of routes, created manually for every category and brand.

Maybe it's better to use a 'detection controller', that checks if the first segment is a category or a brand, and redirect to the correct controller.
If you use an HMVC solution, you could opt to call the correct controller directly instead of redirecting, which will preserve the URL, but is a 3rd-party solution.