Welcome! Log In Create A New Profile

Advanced

Re: Need help with regex

July 20, 2018 07:32AM
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.eduhttp://web.yale.edu/


From: nginx <nginx-bounces@nginx.org> on behalf of Michael Friscia <michael.friscia@yale.edu>
Reply-To: "nginx@nginx.org" <nginx@nginx.org>
Date: Friday, July 20, 2018 at 7:10 AM
To: "nginx@nginx.org" <nginx@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.eduhttps://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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Need help with regex

wickedhangover July 20, 2018 07:12AM

Re: Need help with regex

wickedhangover July 20, 2018 07:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready