views:

31

answers:

1

is there a way to hide IDs using only .htaccess and without changing my php code?

htt://www.domain.com/show.php?categoryID=2&cname=electronic&productid=21&name=laptops

to

htt://www.domain.com/electronics/laptops

thanks in advance.

+2  A: 

In your .htaccess you can put:

RewriteEngine On
RewriteRule ^(electronics|other|categories|here)/(laptops|other|products|here)/$ shop.php?cname=$1&name=$2

Basically I made a RegEx that matches all of your products and all of your categories, and broke that out into the cname and name and passed them to show.php.

However note I didn't pass the ID numbers to your show script. Rewrite Engine can't figure those out for you, your script will need to take the names and look up the ids itself.

SoapBox
thanks for clarifying!
keithics