Problems with simple regex
-
I’m having some issues with a simple regex that I can’t find any answers to.
I am redirecting URLs from an old html site to product categories on my WordPress/WooCommerce site. The old URLs are complex and rather than redirect every product I am matching a partial URL to the top level category.
http://www.evatron.com/index-pag-products-cid-1-sid-1-l-2.html
Redirects to:
http://evatron.com/product-category/desk-consoles/
But I am only matching this part of the URL which references a product category number:
/index-pag-products-cid-1
Using this regex:
/index-pag-products-cid-1(.*)Works lovely, until I get into double digits at the end of the original partial URL:
/index-pag-products-cid-11(.*)Should go here:
http://evatron.com/product-category/rectangular-potting-boxes/
But ends up at the same URL as the first redirect:
http://evatron.com/product-category/desk-consoles/
Am I doing something wrong with my regex markup? I tried disabling the original
/index-pag-products-cid-1(.*)to test if then the double digit URLs worked, but it made no difference…Any help would be much appreciated.
The topic ‘Problems with simple regex’ is closed to new replies.