I updated my site twice since the last year and I have different page names since my first version. Is it possible to create dynamic rules in apache?
for example:
I use to have these pages (example):
I want to create a rule that will redirect abc123 to abc_123 if it exists and abc_123 to abc-123 if it exists. Thanks
Why not this?
RewriteRule ^([a-z]+)([0-9]+)$ /$1-$2 [NC,L]
RewriteRule ^([a-z]+)_([0-9]+)$ /$1-$2 [NC,L]
EDIT:
or you can use 1 rule:
RewriteRule ^([a-z]+)(_?)([0-9]+)/?$ /$1-$3 [NC,L]
this way it's easy to add characters in the (_?)
instead of creating the same rule over and over with a little variance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With