Reputation: 2529
I can't seem to figure out this specific regex htaccess rewrite, and could use some assistance. I'm trying to go from this:
mysite.com/product/13202102/any-random-product-name
and rewrite to this url:
mysite.com/product.php?id=13-2021.02
Note that the id will always have exactly 8 numbers, and will always require a dash (-) after the first 2 digits, and a period (.) before the last 2 digits. The tailing string is irrelevant, but I'd like the url to work with or without a trailing slash (/).
Upvotes: 2
Views: 651
Reputation: 143966
Try:
RewriteRule ^/?product/([0-9]{2})([0-9]{4})([0-9]{2})/? /product.php?id=$1-$2.$3 [L]
Upvotes: 1