Fetching a string by parsing URL

sudharshanr nginx-forum at nginx.us
Wed Jul 22 23:31:54 UTC 2015

For some reason, I'm getting it as null. This is my config file:

map $uri $last_path {
~*/(?<pathname>[^/]+)/?$ $pathname;

server {
    listen       80;
    root /basefolder;

    error_page 500 501 502 503 504 =
    location  ~*/error5x.html? {
       alias <static file location>/error5x.html;

    location ~*/path1/  {

        if (-f $document_root/error503.html) {
          return 503;

However, if I update the location directive as below:

location  ~*/error5x.html? {
       alias <static file

I get a file not found error. But when I check the nginx log, I can see that
it is fetching the $last_path variable. Just that it takes it as part of the
file name and throws a 404 error.


Posted at Nginx Forum: http://forum.nginx.org/read.php?2,260458,260498#msg-260498

More information about the nginx mailing list