I am trying to write a regular expression for apache virtual host configuration that will map request if URI doesn’t have certain extensions. Below expression I have written.
^/bookdata/.+.(?!jpg|mp3|mp4|zip|doc|pdf|xls|xlsx).*$
Below URI is not matching to this expression which is perfectly fine.
/bookdata/rw0/media/Q2e_00_RW_U08_Q_Classroom.mp3?fd=1
My problem with below URI which is matching with this expression due to two dots.
/bookdata/rw0/media/ELM2_U02_Track06_Chart2.8.mp3?fd=1
Any small help will be appreciated.
2
Answers
Put the neg. lookahead right at the start, like so
See a demo on regex101.com.
As I know request URI doesn’t contain request params(after question mark)
So you can ommit .* at the end of your regex then you can match your prefer uris.
This happen because you say that your uri end by those extension must not match.