Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex match urls NOT containing given set of strings

I need to match all urls that DO NOT contain either /admin/ or ?page=.

I'll be using this as a redirect rule in an iirf.ini file (supports htaccess syntax).

How can I accomplish this?

like image 248
samoyed Avatar asked Dec 05 '22 20:12

samoyed


1 Answers

Use a negative look-ahead (?!...) with a regex OR (a|b):

^(?!.*(/admin/|\?page=))

This is saying that when positioned at the start (^) the input should contain either of your two test strings

like image 144
Bohemian Avatar answered Jan 03 '23 07:01

Bohemian