Implementation method
Add map
directive rules in the http
domain of nginx.conf, which contains a url rule mapping file:
# 设置301跳转 map $request_uri $new { include /etc/nginx/redirect.map; }
map
The command supports the introduction of a mapping file. The content format of the redirect.map file here is as follows:
~^/page/mordern-php$ /page/modern-php;
Currently only one line is added as a test, the front can be Regular expression, followed by the new url to jump to, and each line ends with a semicolon.
Since the website has https enabled, in the server
block that listens to port 443, add the following rule before the location
statement:
if ($new) { rewrite ^ https://www.tanteng.me$new redirect; }
This statement means If the url matches the rule in redirect.map, jump to the new url rule.
Restart the nginx service and you can see the effect.
The above is the detailed content of How to use Nginx's map instruction to achieve page jump. For more information, please follow other related articles on the PHP Chinese website!