nginx wordpress link (url pseudo static) 301 permanent Redirection Implementation Method _nginx

Source: Internet
Author: User


In several blog programs toss the results ~
Causes the URL to change two consecutive times. This is the third time.
Nginx through rewrite use "permanent;" The parameter is 301 permanent URL redirection.
The previous URL structure
The URL structure you need now
Learn Nginx configuration rules, learn regular expressions (I have not contacted, learn Bai.) )
Nginx's Chinese Veken:
Getting Started with regular expressions: Http://

The simple explanation (earnest study regular expression-I did not study seriously ^_^):
^ Represents the beginning of a matching string.
$ indicates the end of the matching string.
$ $ represents a variable
([0-9]+) represents at least 1 numeric strings with a maximum of no restrictions.
The head looks dizzy (not the programmer.) )。 Writes out an expression.

Copy Code code as follows:

<a class= "title=" rewrite under href= "St_tag internal_tag" >rewrite</A> ^/post/([0-9]+)/$/archives/$1.html Permanent;
<a class= "title=" rewrite under href= "St_tag internal_tag" >rewrite</A> ^/html/y2009/([0-9]+). html$/archives/$1.html Permanent;

Add an expression to the Nginx conf file.
Put it here.
Complete configuration:

This is my complete wordpress nginx rewrite rule configuration.
1, nginx rewrite URL change 301 redirect.
2, Nginx rewrite redirect to
3, nginx WordPress rewrite pseudo static rules (to support WordPress custom URL).

Copy Code code as follows:

Rewrite ^/post/([0-9]+)/$/archives/$1.html Permanent;
Rewrite ^/html/y2009/([0-9]+). html$/archives/$1.html Permanent;
if ($host!~ "^www\.iamle\.com$") {
Rewrite ^ (. *)$1 permanent;
if (-f $request _filename/index.html) {
Rewrite (. *) $1/index.html break;
if (-f $request _filename/index.php) {
Rewrite (. *) $1/index.php;
if (!-f $request _filename) {
Rewrite (. *)/index.php;

Test results:
Access: be jumped to

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.