Trying to write a rule for a WP redirect
I’ve got the rule ^((?!json).)*$
Which ignores:
- /wp-json/aber
And the rule ^([^.\?]*[^\/])$
Which ignores:
- /aber.css
- /france?foobar=1
But I can’t seem to figure out how t combine them into a single rule that ignores all three. if I add [^.?|json] if rules out any URLs including any of those characters individually. It only needs to be exactly "json" located anywhere in the URL or URLs that include a . or a ?
Examples:
Dont match:
- /wp-json/aberdeen
- /aberdeen.css
- /aberdeen?foobar=1
Match:
- /wp-jsn/aberdeen
- /aberdeen
>Solution :
Well the first pattern ^((?!json).)*$ simply asserts that json does not appear anywhere in the input. We can refactor the second pattern by adding a negative lookahead to rule out json:
^(?!.*json)([^.\?]*[^\/])$