Debugging NGINX location regex-rules

Nginx has unfortunately no really usable “rewrite log” for regex location matches. But you can create your own small (but sometimes very useful) debug output:

    location ~ ^/(.*?)/(.*)  {

        return 200 'Debug: 1:$1  2:$2';
        add_header Content-Type text/plain;

        # try_files $uri /$1/index.php?$args;

Nginx now simply returns the generated content:

Debug: 1:xxxxx  2:yyyyy

The add_header statement is used to force text-output if you’re debugging using a web-browser (otherwise a download would be created).