I'm creating a website that includes a country/state/city browsing interface. For SEO purposes, I want to include the name of the country/state/city in the URL. For example, the URL may include additional variables and would be something like:
http://www.domain.com/USA/NewYork?Category=car&color=black&Model=2009&page=5
http://www.domain.com/Spain/Allcity?Category=car&color=black&Model=2009&page=20
I need to fit this functionality into CodeIgniter. I'm not sure how to organize the major components, specifically the Controller, and possibly the Library class.
Is there a standard or best practice approach?
Edit the
routes.php
file located in your config folder.As noted in the link from Bora (CI URI Routing) Some examples from the documentation:
In your case you need to reconcile the names of the functions in your controllers and the desired URL names. You could end up with the examples that you show in your question, but you'd have to lay out a route for every country that you want in the first URI segment after domain.com. It's probably easier to do this:
http://www.domain.com/locations/USA/NewYork?Category=car&color=black&Model=2009&page=5
And then in your routes folder:
If you need to pass additional parameters to your controller via URL you can use query strings as you show above, or add