Nginx deeper -Rewrite

Scenario advantages: URL access redirection, compatible support,   SEO optimization,    background maintenance, traffic forwarding,   safe

Syntax:

   Syntax:    rewrite   regex (regex式)  replacement   [flag];

  Context:   server,location, if

For example, maintenance interface

  rewrite ^(.* )$ /pages/maintain.html break;

flag:

  last      stop detection A new request will be created

  break     stop detection No new request will be created, first make sure the request exists

  redirect   returns to 302 temporary redirection, the address bar shows the address after the jump

  permanent  returns to 301 permanent redirection , The address bar shows the address after the jump

The difference between last and break

share picture

redirect Difference from last

< p>The client will create a temporary 302 request target before the /test/ request /test/ There are 2 requests in response

Last will have one request

permanent

After nginx is stopped, the requested interface will also be cached in the browser< /p>

redirec t It is only a temporary cache, and it will be slower to request again

Some common configurations

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4614 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.