![]() |
Need advice on SEO friendly URLs - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Need advice on SEO friendly URLs (/showthread.php?tid=22225) |
Need advice on SEO friendly URLs - El Forum - 09-01-2009 [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 Need advice on SEO friendly URLs - El Forum - 09-01-2009 [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. Need advice on SEO friendly URLs - El Forum - 09-02-2009 [eluser]zuluanshee[/eluser] ill give it a try tomorrow and let you know. Thanks. Need advice on SEO friendly URLs - El Forum - 09-02-2009 [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 Need advice on SEO friendly URLs - El Forum - 09-02-2009 [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"; Need advice on SEO friendly URLs - El Forum - 09-02-2009 [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. Need advice on SEO friendly URLs - El Forum - 09-02-2009 [eluser]garycocs[/eluser] Any chance you'd like to share the DB of cities?? ![]() Need advice on SEO friendly URLs - El Forum - 09-02-2009 [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. Need advice on SEO friendly URLs - El Forum - 09-02-2009 [eluser]zuluanshee[/eluser] You can get a zip of all the cities in teh world here: http://www.maxmind.com/download/worldcities/worldcitiespop.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. Need advice on SEO friendly URLs - El Forum - 09-03-2009 [eluser]garycocs[/eluser] In fact ah nice one!!! |