mod rewrite help
- by Benny B
Ok, I don't know regex very well so I used a generator to help me make a simple mod_rewrite that works.
Here's my full URL
https://www.huttonchase.com/prodDetails.php?id_prd=683
For testing to make sure I CAN use this, I used this:
RewriteRule prodDetails/(.*)/$ /prodDetails.php?id_prd=$1
So I can use the URL
http://www.huttonchase.com/prodDetails/683/
If you click it, it works but it completely messes up the relative paths. There are a few work-arounds but I want something a little different.
https://www.huttonchase.com/prod_683_stainless-steel-flask
I want it to see that 'prod' is going to tell it which rule it's matching, 683 is the product number that I'm looking up in the database, and I want it to just IGNORE the last part, it's there only for SEO and to make the link mean something to customers.
I'm told that this should work, but it's not:
RewriteRule ^prod_([^-]*)_([^-]*)$ /prodDetails.php?id_prd=$1 [L]
Once I get the first one to work I'll write one for
Categories: https://www.huttonchase.com/cat_11_drinkware
And database driven text pages:
https://www.huttonchase.com/page_44_terms-of-service
BTW, I can flip around my use of dash and underscore if need be.
Also, is it better to end the URLs with a slash or without?
Thanks!