In actual configuration, in some cases, using last does not work. You can change it to break. The principle is that you have different understandings of the root directory, which is roughly the same as my test results. # Location {# proxy_passhttp: test; # aliashomehtml; # roothomehtml; # rewrite ^ a (. *) \ .html#1.html last;
In actual configuration, in some cases, using last does not work. You can change it to break. The principle is that you have different understandings of the root directory, which is roughly the same as my test results.
# LoCatIon /{
# Proxy_pass http: // test;
#Alias/Home/html /;
# Root/home/html;
# ReWrite^/A/(. * pai.html $/1.html last;
#}
In the # location/{Configuration:
1. Use root to specify the Source: either last or break can be used.
2. Use proxy_pass to specify the Source: either last or break can be used.
3. Use alias to specify the Source: You must use last
In location/a/or useRegular ExpressionLocation ~ ^/:
1. Use root to specify the Source: either last or break can be used.
2. Use proxy_pass to specify the source: the break and last results are different.
3. Use alias to specify the Source: You must use last
The main difference lies in the proxy_pass label. Let's take a look at several test results:
Location /{
Root/home/html;
}
Location//{
Proxy_pass http: // test;
Rewrite ^/a/(. * pai.html $/1.html last;
}
In this configuration, you can access things using last access. However, the result is:/home/html/1.html; but what I need is http: // test/1.html? Use break.
Location /{
Root/home/html;
}
Location//{
Proxy_pass http: // test;
Rewrite ^/a/(. * pai.html $/a/1.html last;
}
In this configuration section, an error is returned because the last request will re-initiate a request match, resulting in an endless loop. You can use break to access http: // test/a/1.html.
Therefore, using last will re-initiate a request to the server tag, and break will directly use the data source in the current location for access, which should be used as needed. Generally, rewrite is configured in a non-root location, and break is used. It is better to use last for the root location, because if fastcgi or proxy is configured to access the jsp file, using break in the root location cannot be accessed. If there is a problem with rewrite, you may try to replace the two.
When using alias, it is estimated that the last time must be used, which is limited by nginx itself. How to try break cannot be successful.