views:

48

answers:

2

Hello.

I want to make a rule that transform this URL:

http://www.example.com/product.php?category=1&product=5

Into

http://www.example.com/brother-2035 (The product name can be retrieved from my mysql database and is "Brother 2035").

+1  A: 

Your need to set up a PHP or ASP Redirect page. Mod_Rewrite cannot access the database, so you want to set up a page that goes, finds the product, and redirects to the URL using a header.

header("Location: example.com");
Chacha102
+1  A: 

You cannot get anything from a database with mod_rewrite.

What you need to do is rewrite "http://www.example.com/brother-2035" to (for example) a php file:

RewriteRule ^(.+)-(\d+)$ /product.php?company=$1&id=$2

and then access the database from within product.php.

slosd