Need help with regex

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


Ok, never mind. It was working all along. My HOSTS file was screwing me up and pointing to a local instance that did not have this config.

___________________________________________
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/>


From: nginx <nginx-bounces at nginx.org> on behalf of Michael Friscia <michael.friscia at yale.edu>
Reply-To: "nginx at nginx.org" <nginx at nginx.org>
Date: Friday, July 20, 2018 at 7:10 AM
To: "nginx at nginx.org" <nginx at nginx.org>
Subject: Need help with regex

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<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fweb.yale.edu%2F&data=02%7C01%7Cmichael.friscia%40yale.edu%7C6b9e01cf30984117666608d5ee316ef7%7Cdd8cbebb21394df8b4114e3e87abeb5c%7C0%7C0%7C636676818438018563&sdata=W29V4RrK%2F4T3ESBQVGImY%2FXxRNxHmmSsLV8QkCY1jnw%3D&reserved=0>

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


More information about the nginx mailing list