Need help with regex

Friscia, Michael michael.friscia at yale.edu
Fri Jul 20 11:10:25 UTC 2018


I have a regex that works in an online tool but when I put this into my configuration file it is not working.

The problem is that I want all URLs that start with /info to be redirected with the exception of one unfortunately named PDF file. This regex tests perfectly in an online tool
^/info(\/)?(?!\.pdf)
which shows that anything /information /info and /info/ all redirect and this will not /informationforFamiliesAlliesPacket_298781_284_5_v1.pdf
But when I put this into action, the PDF requests are still being redirected like any other /info call made.

I use a config file with a number of redirects so the full location block is simply:
location ~* ^/info(\/)?(?!\.pdf)      {          return 301 https://www.yalemedicine.org/conditions/; }

My thought process was to still redirect unless “.pdf” existed in the URL just in case we upload more “info….pdf” documents into the system, I didn’t want to make this exception too specific.

Any thoughts on this would be great, my regex skills are good enough most of the time but failing me right now.


___________________________________________
Michael Friscia
Office of Communications
Yale School of Medicine
(203) 737-7932 - office
(203) 931-5381 - mobile
http://web.yale.edu<http://web.yale.edu/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20180720/f18e3768/attachment-0001.html>


More information about the nginx mailing list