Home >CMS Tutorial >WordPress >How to set pseudo-static links in WordPress

How to set pseudo-static links in WordPress

藏色散人
藏色散人forward
2021-07-12 14:51:493140browse

The default link form of the wordpress page adopts the "plain" method (for example: http://domain name/?p=123)

Such a dynamic URL The link is not convenient for search engines to include. For this reason, we need to set it to several other common fixed link forms, such as http://www.sufaith.com and choose [custom structure].

The setting method is as follows:

Enter the homepage of the WordPress backend system, click the menu [Settings]-[Permanent Link]

How to set pseudo-static links in WordPress

Select [Common Settings] 】【Customized structure】, you can choose a single tag or a combination of multiple tags, and you can customize the splicing string. This site uses /%post_id%.html. After filling in, click [Save changes]. It takes effect.

How to set pseudo-static links in WordPress

After saving the changes, although the link to the article or page becomes a fixed link, when accessing the page, it becomes a download operation and the page cannot be accessed normally. URL address, then you need to configure nginx’s pseudo-static (URL Rewrite) rules.

The following is the configuration of nginx, which needs to be modified to your own domain name and root path.

server {
    listen 80;
    server_name www.example.com;
    root /usr/local/www/wordpress;
    index index.php index.html index.htm;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

After modifying the configuration After that, restart nginx to take effect and restore normal access.

systemctl restart nginx.service

For more WordPress technical articles, please visit the WordPress tutorial column!

The above is the detailed content of How to set pseudo-static links in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete