• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need a little Regex help

DaiShan

Diamond Member
Ok, I'm trying to use mod_rewrite to rewrite URL's of the form
/promotional-products/product.php to /promotional-products/products.php?cat=product

E.G.

/promotional-products/t-shirts.php no longer exists as a php file. Instead products.php will now create the page from the database, but for search engine reasons we still want the user / search engine to be able to click on the link and be taken to the following address: /promotional-products/products.php?cat=t-shirts Here is the regex I have:

RewriteEngine On
RewriteRule ^/promotional-products/*$1 /promotional-products/products.php?cat=$1 [PT]

I've tried many permutations of this from many separate tutorials, but nothing seems to work (mod_rewrite is installed and enabled) Can someone please point me in the right direction?
 
Try to see if this works (note that i didn't test them so it might not work):

RewriteRule ^promotional-products/(.+)\.php$ promotional-products/products.php?cat=$1 [L]

To enable callback (or whatever it's called), you need to enclose the expressions in (parantheses), and then refer to them as $1, $2, etc.
 
/edit You had it right, we both forgot the leading slash however. For those who are interested this is the full code:

RewriteEngine On
RewriteRule ^/promotional-products/(.+)\.php$ /promotional-products/products.php?cat=$1 [L]

Thanks!
 
Glad to know it worked -)

IIRC, you can also put this before your RewriteRule so you don't have to put a leading slash:

RewriteEngine On
RewriteBase /

RewriteRule ..... blah blah blah


-stndn.
 
Back
Top