Welcome! Log In Create A New Profile

Advanced

Rewrite doesn't work if location has no trailing /

Reiner Bühl
February 09, 2019 05:52AM
Hi all,

I currently use the following location to redirect every request for a
resource under /webmail to a seperate server:

location /webmail {
rewrite ^/webmail(.*) /$1 break;
proxy_pass http://127.0.0.1:8081;
proxy_redirect off;
proxy_set_header Host $host;
}

This works fine for URLs like /webmail/ or /webmail/<*>. However if the
URL is just /webmail - no trailing / - then the page itself is served
from the other web server but all resources like pictures that are
referenced in that page do not get rewriten. If I call the same page
with /webmail/, all resources in the page are properly rewritten and
load correctly.

Can you give me a hint what to change in the rule?

Best regards,
Reiner
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite doesn't work if location has no trailing /

Reiner Bühl February 09, 2019 05:52AM

Re: Rewrite doesn't work if location has no trailing /

nanaya February 09, 2019 05:56AM

Re: Rewrite doesn't work if location has no trailing /

reibuehl February 09, 2019 08:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 90
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready