Clean URLs to make search engines your friend

From Wiki.TheWomo

Jump to: navigation, search

The structure of your website's url means a lot to search engines like Google while crawling & ranking your website. URLs that speak for itself are more prone to making it to the top results. Besides, such URLs are more acceptable to users in email, instant messaging, chatrooms, blogs & forums. You happen to get a gist of what you can expect on the page before you even click on it.

The cleanest URLs are the one's that make your website look as static as possible!

Clean, Friendly & Meaningful URLs:

http://wikipedia.org/wiki/Taj_Mahal *****
--> Some information on the Taj Mahal

http://ecomantra.com/trip/26/andaman-islands-sun-sea-sand-snorkeling-and-scuba.html *****
--> Some holiday trip in Andaman that got something to do with sun, sea, sand & scuba

http://greengrowerindia.com/services/retail_wholesale_plants.php **
--> Retail & Wholesale plants is a service of greengrowerindia

http://mumbaivotes.com/politicians/1/ ***
--> A politician that got something to do with Mumbai voting

Avoid the Unfriendly (dirty) URLs:

http://example.com/s/ret_plants.php
http://example.com/cont.html
http://example.com/products/index.php?pid=254
http://example.com/?cat=2&p=1
                               ...huh?

Contents

I agree, let's clean my URLs

Depending on the kind of website you are coding, you will have to pick the right approach from below. Remember, it's always best to plan out the URL structures of your website before you actually start coding it for various reasons like backlinking & broken links. It is tougher to attain this on an already built dynamic site where you have already named your code files & classes. For this reason, you shouldn't ever assume that the team carrying out the SEO optimization will be in a position to make URL changes. In case a site you developed does go for SEO, it will bounce back to you!

1. Static Websites

Clean URLs can be attained on more or less static websites (like http://greengrowerindia.com/) by simply renaming filenames to fit descriptive keywords. Use strong dictionary words to categorize similar files into folders. Use a hyphen ('-') to separate two different words. (Avoid underscores and other special characters) For example:

http://example.com/                                       <-- home page
                  /about.html                             <-- about page
                  /services/                              <-- the services entry page (located in services/index.html)
                  /services/heart-treatment.html          <-- a page on heart-treatment
                  /services/dental-care.html
                  /services/others/weight-loss-diet-program.html <-- Do not worry about length, concentrate on the keywords
                  /pages/how-artificial-kidney-works.html <-- a random page

If you use very little php in your site and want to get rid of the ugly .php extensions randomly sticking around, you can make php execute in .html files. How to Run PHP in HTML Pages

2. Dynamic Websites

For dynamic websites built in php, there are many ways to go about making your URLs search friendly. The finest & right way to do it is using Apache's mod_rewrite module. It is used by Wordpress, Wikipedia & all the best content sites out there! Though this method does require a lot of coding work, in an MVC approach - it makes your code well organized. PHP Frameworks like CodeIgnitor also support it though we do not recommend using any.

For example, take the case of the url
http://ecomantra.com/trip/29/goa-and-karnataka-where-mountains-meets-wildlife.html
It is of the syntax http://domain.com/trip/##id##/<<dummy-text>>.html
What the URL is actually requesting is a 'trip' with 'id' = 29 in the database table. This information is retrieved & displayed using a combination of php logic along with a .htaccess file which sets up the mod_rewrite. The rest of the text doesn't really matter and is just for the sake of SEO.

Using Apache's mod_rewrite with PHP:

--Dayson 19:33, 2 May 2009 (UTC)

Personal tools