Need advice on SEO friendly URLs |
[eluser]zuluanshee[/eluser]
I'm building a travel site. People will access cities through a tree of sorts. I want to create urls that say mytravelsite.com/Europe/France/Paris mytravelsite.com/Europe/Italy/Rome mytravelsite.com/Asia/China/Beijing I'm doing this in part because I want to implement breadcrumbs. My question: is mod_rewrite the only way to do this? There will be a lot of cities. In fact, I've found a list of every city in the world and plan on building a database I'm afraid i know so little about mod_rewrite, I don't know if this can even be done easily. Does every single city have to be mapped in .htaccess? My city list has about 250,000 cities in it. Or, is there a 'built-in' way to do this with CI? thanks
[eluser]brianw1975[/eluser]
I wouldn't even use mod_rewrite.... read http://ciuserguide/general/routing.html Code: $route['([A-Za-z]+)/([A-Za-z]+)/([A-Za-z]+)'] = "region/$1/country/$2/city/$3"; Code: function city($cityname){}; I think that should (read: might?) be able to do your routing. I never was very good at RegEx... of course you will want to put in checks for valid entries, and some modifications for city and country names with spaces, etc.
[eluser]zuluanshee[/eluser]
ill give it a try tomorrow and let you know. Thanks.
[eluser]brianw1975[/eluser]
actually, looking at that again... that won't work at all..... not sure what I was thinking at the time....my only excuse is being stuck in session purgatory... hopefully someone else can chime in
[eluser]aquary[/eluser]
You are having the same problem I had before. I asked in the forums and some guy came up with this solution. I don't have the actual codes now, but it looks like these: Code: $route['(:any)/(:any)/(:any)'] = "location/city/$3"; Now, that solved the problem, but a new problem arise. All of the link will go to "location" controller, so you have to put more routing rules for all others controllers. Code: $route['contact'] = "contact/default";
[eluser]John_Betong[/eluser]
I have problems with routing and mod_rewrite so I would go for this simple(?) solution Because there are only five continents then have a controller for each continent. 1. NOT REQUIRED: // Each controller inherits a common MY_Controller 2. the index function is passed two variables, $country and $city. 3. these two parameters are used to query a database table 4. the results are passed to a common view function. Code: <?php edit: removed MY_Common_Controller, added Home page is no parameters passed. N.B. Please note this code has not been tried and tested.
[eluser]Johan André[/eluser]
There are complete databases of cities (with zipcodes, areacodes, longitude, latitude etc) to buy... I bought one with all swedish zipcodes, cities, municipals etc.
[eluser]zuluanshee[/eluser]
You can get a zip of all the cities in teh world here: http://www.maxmind.com/download/worldcit...pop.txt.gz caveat: the country is in two letter code. And some countries like England and Wales are listed under GB. You'll have to finagle it to get it right.
|
Welcome Guest, Not a member yet? Register Sign In |