WordPress blog's original fixed link mode is: http://site.com/archives/%post_id%.html
Now I want to change to: http://site.com/%post_name%
Requirements:
1. The old article (http://site.com/archives/%post_id%.html) can jump 301 to the new fixed link mode
2. New article is http://site.com/%post_name%
Method:
0. Prerequisites
-Warning: tossing is risky !!! Database operations are involved. Please back up the database carefully before any effort !!!
-The front-end server is Nginx (self-conversion of Apache)
1. Database operations: change the post_name value in the wp_post table to post_ID in batches.
-Log on to your phpmyadmin
-Click your database name and then click the "SQL" tab.
-Paste the following SQL statement into the box below "run SQL query in database ooxx (database name):"
UPDATE wp_posts SET post_name = REPLACE (post_name, post_name, ID) WHERE post_type = 'post'
-Click Run.
2. Modify the WordPress fixed link: fixed link in settings of WP background, and change the "custom structure"
/% Postname %
3. Configure Nginx redirection (301 transfer to the old link)
-In your website configuration, find
Location /{
....
}
Add
Location/archives /{
Rewrite ^/archives/(. * pai.html http: // your domain name/$1 permanent;
}
-Restart Nginx.
Other methods can be used to draw the opposite line.