Passing variable through .htaccess

Hi,

Finding my way around .htaccess and in particular with mod rewrite. However, need some advice as to how to achieve my url to appear like this:

http://www,mysite.com/category-brand-product.html

by passing variables. I can get this to work but I have to use the variable values within the re-written url, like so:

http://www.mysite.com/cheese-b-1-p-2.html
where b represents brand and p represents product. I need to pass the values through to the next page and retrieve them using $_GET.

Ideally, I would like to have the url as such;
http://www.mysite.com/cheese-edam-block-of-cheese.html

Is this possible and if so, what’s the best way to go about this. Can you hide the values past through the URL?

An example of my rewrites:


RewriteRule ^([a-z0-9/-]+)-b-([0-9]+)-p-([a-z0-9/-]+).html$ product.php?&brand=$1&prod=$2

Cheers

You can’t do this using just the .htaccess, you need to change your code as well.
What you’re after is a thing called slugs, see for an example tutorial here: how to use generated slug (using .htaccess) | TechnoReaders.com

freaky,

IMHO, you’ve not got your head around your problem, i.e., category-brand-product does not translate to cheese-b-1-p-2 nor to cheese-edam-block-of-cheese. Without an ability to “map” your category, brand and product to the URI (and from the URI to the database in the target file), you will fail with any mod_rewrite attempt. Think: SPECIFICITY!

cheese - either provide a list of acceptable cheese types or require your “cheese” variable to be a test string of lowercase characters (NO -'s, no CAPS, nada!). Use ([a-z]+)- where the last - is the demarker character to separate the cheese from the brand.

brand - easier to specify the few acceptable brands (i.e., (Kraft|Borden|generic)- ).

product - could be either of the above - just be sure to eliminate the spaces or you’ll end up with %20 in their place!

Once you’ve got “specificity” like that, it’s easy to write the mod_rewrite code.

Regards,

DK

Thanks for the help and advice guys. looking into it more now