The words in the URL might match the search keywords, bringing more traffic from search engines. The seo friendly url is like to same as that http://mysite.com/index.php?product=productname&price=30 to http://mysite.com/products/productname/30/. I have no worry about the seo friendly url because I used to like  htaccess and mod rewrite. It is so easy to rewrite a url to seo friendly.









Creating .htaccess file: Just open a notepad (windows notepad) and save the file as ".htaccess" without any extension. Because .htaccess is the extension. It’s not htaccess.html or index.htaccess; it’s simply .htaccess.

Server configurations:  Write in file  the two lines.
  1. Options +FollowSymLinks 
  2. RewriteEngine On
Create your own rewrite rule:
Example 1:  If you want to change links like http://mysite.com/index.php?topic=rules to http://mysite.com/topic/rules/, here’s the rewrite rule.
  1.  Options +FollowSymLinks     
  2.  RewriteEngine On
  3.  RewriteRule ^topic/([a-zA-Z0-9]+)/$ index.php?topic=$1
    
        • Like regular expressions, the [a-zA-Z0-9] matches lower and uppercase of alphabets and numbers.
        • The asterisk inside the brackets + is a quantifier that match 1 occurrence to infinite concurrences.
        • Combining them, ([a-zA-Z0-9]+) matches alphanumeric of at least 1 character.
        • The caret ^ means “start with”, meaning the URL starts with the word “topic”.
        • The dollar sign $ means “end”, meaning the URL ends with a slash.
        • The $1 is back reference, it carries the content of the first group of brackets.

        In other words, when user enters http://mysite.com/topic/faqs/ , the page being called and run would be http://mysite.com/index.php?topic=faqs

Example 2:    If you want to change URLs like http://mysite.com/index.php?product=productname&price=30 to http://mysite.com/products/productname/30/. here’s the rewrite rule.
  1.  Options +FollowSymLinks     
  2. RewriteEngine On
  3. RewriteRule ^products/([a-zA-Z]+)/([0-9]+)/$ index.php?product=$1&price=$2
       
        • The [0-9] in matches numbers only.
        • The plus sign is a quantifier that match 1 or more occurences.
        • Combining them, ([0-9]+) means 1 or more numbers.
        • Similarly, $1 will be the first brackets : product name and $2 would be the second brackets : price.

Example 3:    If you want to change URLs like http://mysite.com/article.php?id=45 to http://mysite.com/article-45.html, here’s the rewrite rule.
  1. Options +FollowSymLinks         
  2. RewriteEngine On
  3. RewriteRule ^article-([0-9]+)\.html$ article.php?id=$1

        • The new thing here is the \. (backslash followed by a dot).
        • The backslash here “escapes” the dot, so that the dot means a real dot instead of “anything”.

Example 4. Redirect non-www to www:

  1.   RewriteEngine On
  2.  Options +FollowSymLinks
  3. RewriteCond %{HTTP_HOST} ^mysite.com [NC]
  4. RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
           
Example 5. Redirect www to non-www:

  1. RewriteEngine On
  2. Options +FollowSymLinks
  3. RewriteCond %{HTTP_HOST} ^www.mysite.com [NC]
  4. RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301]
       
Example 6.    Redirect an old page to a new page.

  1. Options +FollowSymLinks
  2.  RewriteEngine on
  3.  Redirect 301 /oldpage.html http://www.mysite.com/newpage.html

Example  7.    Redirect several pages to one as like example 6

  1. Options +FollowSymLinks
  2.  RewriteEngine on
  3. Redirect 301 /seattle-companies.html http://www.mysite.com/seattle-company.html
  4. Redirect 301 /seattle-locations.html http://www.mysite.com/seattle-company.html   
           
Example 8.  Hide extention of the page as http://www.mysite.com/news.php to http://mysite.com/news.

  1. Options +FollowSymLinks           
  2. RewriteEngine on
  3. RewriteCond %{REQUEST_FILENAME} !-d
  4.  RewriteCond %{REQUEST_FILENAME}\.php -f
  5.  RewriteRule ^(.*)$ $1.php
       
       
Example 9.  Custom 404 error page, put this in your htaccess if you would like to have a custom 404 error page instead of the default one.

  1. Options +FollowSymLinks           
  2. RewriteEngine on
  3. ErrorDocument 404 /404.php

    
 Example 10.  Disable directory browsing for security purpose, its best to disable directory browsing so that people won’t know what files you have.
  1. Options +FollowSymLinks           
  2. RewriteEngine on
  3. Options All -Indexes
 Example 11.  Redirect 301 permanent,  Search engine bot that visits the old file will be redirected to the new site. Site is redirect to the http://www.newsite.com from your site as te http://www.mysite.com

        RewriteEngine On
        RewriteBase /
        RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]
       

Some others Command Flag Block:
        [R]     Redirect you can add an =301 or =302 to change the type.
        [F]     Forces the url to be forbidden. 403 header
        [G]     Forces the url to be gone 401 header
        [L]     Last rule. (You should use this on all your rules that don't link together)
        [N]     Next round. Rerun the rules again from the start
        [C]     Chains a rewrite rule together with the next rule.
        [T]     use T=MIME-type to force the file to be a mime type
        [NS]     Use if no sub request is requested
        [NC]     Makes the rule case INsensitive
        [QSA]     Query String Append use to add to an existing query string
        [NE]     Turns of normal escapes that are default in the rewriterule
        [PT]     Pass through to the handler (together with mod alias)
        [S]     Skip the next rule S=3 skips the next 3 rules
        [E]     E=var sets an enviromental variable that can be called by other rules  
  
Protect .htaccess files:  This should disallow other to access your .htaccess file, just like disallowing others to access your wordpress’s wp-config.php
  1. Options +FollowSymLinks           
  2. RewriteEngine on
  3. <files .htaccess>
  4.  order allow,deny
  5.   deny from all
  6.  </files>
        
For more information is here: Link-1, Link-2