RegEx case transformation operator in replacement pattern of Redirection Plugin
-
I tried setting up an enforced redirection of URLs with a single uppercase letter to the canonical URL in all lowercase. Your plugin gave these two recommendations:
- To prevent a greedy regular expression you can use ^ to anchor it to the start of the URL.
- Your target URL should be an absolute URL like https://domain.com/$1 or start with a slash /$1 .
Took this advise to heart. Reshaped my RegEx to:
^/(.[A-Z]+.)
→/\L$1
- Request:
/testing-wordpress/Sample-Page/
- 10 seconds of inactivity. Then my browser shows this:
- Address bar:
/LLLLLLLLLLLLLLLLLLLLtesting-wordpress/Sample-PAge/
- Body: “too many redirects” error message.
It seems the Redirection plugin does not support the case transformation operators like
\L
“to lowercase” in its Replacement Patterns. Instead it seems to have inserted a literal L. Hence it matches itself (uppercase again!) and this leads to an infinite loop. Until at the 20th loop iteration, where a mechanism in the web browser killed this infinite loop.Your plugin support article on Regular Expressions does not mention “Case Transformations” in any form. I guess they are not supported.
- Could you add support for them?
- Or tell me if there is any other way to achieve this case transformation?
- The topic ‘RegEx case transformation operator in replacement pattern of Redirection Plugin’ is closed to new replies.