Tuesday, October 20, 2009

Turn dynamic URLs into search engine friendly static URLs

The original URL
------------------
http://www.scriptscart.com/shop.php?cmd=product&category=vehicles&product=bus

The rewritten URL
--------------------
http://www.scriptscart.com/product/vehicles/bus.html

Add the following lines to .htaccess:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /shop.php?cmd=$1&category=$2&product=$3 [L]

Please follow the instructions below to do it.

  1. First you need to check if the file .htaccess exists in the root of your website.
  2. If the file .htaccess exists, download it from your site, add the lines below to the end of the file, and upload the modified file back to your site. Please make a copy of the original file .htaccess. So if anything goes wrong, you may restore the original file.
  3. If the file .htaccess does not exist, create a new file .htaccess and add the lines below to it. Then upload it to the root of your website. You may delete it if anything goes wrong.