How to get nginx to redirect to another path only if the root path is requested?

leeand00 nginx-forum at
Sun Jan 28 02:36:44 UTC 2018

I have other subfolders in my location paths so for instance other than just
/ after my host, I also have /lang/english/grammar, and

But I figured it out:

        location = / {
               resolver valid=300s;
               proxy_set_header X-Forwarded-Host $host;
	       proxy_set_header X-Forwarded-Server $host;
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	       rewrite /(.*) /$1 break;
	       access_log ./logs/root_access.log;
               error_log ./logs/root_error.log;

The = / that you suggested fixed it right up, thanks!

Posted at Nginx Forum:,278283,278289#msg-278289

More information about the nginx mailing list