CodeIgniter Forums
search engine 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: search engine friendly urls (/showthread.php?tid=27191)



search engine friendly urls - El Forum - 02-03-2010

[eluser]face1m[/eluser]
What is the best way to make my site url's search engine friendly? Currently, I have my controller in the route[default controller] = mycontroller in the route.php file. Thanks.

rick mcelderrry


search engine friendly urls - El Forum - 02-03-2010

[eluser]theprodigy[/eluser]
One of the things I do is, I try to stay away from url's like
Code:
http://www.domain.tld/my_controller/products/1234

I overcome url's like that by having a link_name column in my database set as unique (to avoid duplicate entries), and run my searches based on that column rather then the id.

This allows me to create url's like
Code:
http://www.domain.tld/my_controller/products/my_red_stapler

Most search engines prefer words over id's when dealing with url's, especially when the word is relevant to the content being displayed.

There are several other things you can do, but this is one that I have gotten in the habit of always doing.


search engine friendly urls - El Forum - 02-03-2010

[eluser]face1m[/eluser]
Thanks! That was a very useful post.

rick mcelderry


search engine friendly urls - El Forum - 02-04-2010

[eluser]123wesweat[/eluser]
Quote:This allows me to create url's like
Code:
http://www.domain.tld/my_controller/products/my_red_stapler

is there a difference SEO-wise when using

Code:
http://www.domain.tld/my_controller/products/my-red-stapler

hence _ vs -


search engine friendly urls - El Forum - 02-04-2010

[eluser]theprodigy[/eluser]
I've read somewhere else on this forum that search engines actually prefer hyphens over underscores (so in essence, your way would be better).
Although, I have not done any research on it myself, so I can't actually verify if there is a difference or not.


search engine friendly urls - El Forum - 02-04-2010

[eluser]Peng Kong[/eluser]
i also think hyphens are preferred over underscores but i don't think anyone can be 100% sure that its truly better for SEO. However URL with underscores are hard if they are underlined when being displayed.

Quote:http://www.domain.tld/car_controller/brand_function/volkswagen

that looks ugly right?
so in your route file you can do...

Code:
$route['cars/brand/(:any)'] = "car_controller/brand_function";

which gives you...

Quote:http://www.domain.tld/car/brand/volkswagen