.htaccessurlmod-rewriteseooscommerce

.htaccess rewrite rules for category and product


i have a oscommerce site, i wan to use seo freindly urls, I got a tutorial from here

I basically wanted to change the ID number present in a URL to a URl that will contain name of product or category in it. an example of such url is

http://katanamotorsports.com/innovative-mounts-steel-mounts-prelude-replacement-mount-p-1075.html

i want to modify .htaccess file so that these seo friendly url are actually redirected to respective page with respect to category and product.

i am new bee in learning, and i am totally a new bee in .htaccess

can anybody help me?


Solution

  • You have to use a RewriteRule in your .htaccess to map the external URL (as visible by a user) to your internal version.

    What you want to do is activate the RewriteEngine, then write a RewriteRule that will drop the first part of the URI.

    RewriteEngine on
    RewriteRule ^[a-z0-9\-]+-p-([0-9]+)\.html$ /product.php?id=$1
    RewriteRule ^[a-z0-9\-]+-c-([0-9]+)\.html$ /category.php?id=$1