WordPress fixed link instance change

Source: Internet
Author: User
Tags wordpress blog

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.

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: info-contact@alibabacloud.com 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.