Quick SEO and User Friendly URL Guide

Friendly Image

User-friendly URLs or SEO-friendly URLs are Uniform Resource Locators intended to improve the usability and accessibility of a website by being immediately and intuitively meaningful to non-expert users.

A non-friendly URL is typically composed of a path, script name and query string. The query string parameters dictate the content that is to be shown on the page and frequently includes information opaque or irrelevant to users, such as internal numeric identifiers for values in a database, illegibly-encoded data, session IDs and so on.

To get better understanding, see the following table.

Example Table

In the following, you will see some examples for both non-friendly and friendly URL.

Non-Friendly URL Friendly URL
http://example.com/index.php?page=name http://example.com/name
http://example.com/index.php?page=deparment/finance http://example.com/deparment/finance
http://example.com/products?category=3&pid=35 http://example.com/products/3/35
http://example.com/cgi-bin/feed.cgi?feed=news&frm=rss http://example.com/news.rss
http://example.com/software/index.jsp?category=education&id=math http://example.com/software/education/math
http://example.com/game/index.php?cat=5&id=45 http://example.com/game/5/45
http://example.com/index.php?mod=profiles&id=127 http://example.com/profiles/127

URL Rewriting Implementation

The implementation of user friendly URLs is most often involved transparently rewriting it into the query string form that is easy to understand and meaningful by using .htaccess file.

For search engine optimization purposes, web developers often take this opportunity to include relevant keywords in the URL and remove irrelevant words. The following is an example of .htaccess file for simple website.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
RewriteRule ^product/(.*)$ product_name.php?name=$1
RewriteRule ^contact$ contact.php
ErrorDocument 404 /404.php
RewriteRule ^404 404.php