nginx rewrite

The rewrite directive can be configured in the server block or the location block.

grammar:

rewrite regex replacement [flag];

1. The uri received by rewrite does not contain the host address and does not contain parameters. It can be obtained through the global variables $uri and $args.

2、flag:last、break、redirect、permannet

   last: Abort the processing of the received URI in this location block, and treat the rewritten URI here as a new URI for processing in other location blocks. Make all location blocks rematch and process the new URI.

   break: Treat the rewritten URI as a new URI and continue processing in this block. Execute the rewritten address in the current location block, without redirecting the new URI to other location blocks. The new URI is always in the same location block.

  redirect: 302 temporary redirect.

  permanent: 301 permanent redirect.

3、rewrite_log

   rewrite_log on; Enable URL rewrite log. Output to the log file configured by the error_log directive at the notice level.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324979288&siteId=291194637