Example of how to set WordPress pseudo-static in Nginx

Example of how to set WordPress pseudo-static in Nginx

Quoting Baidu's explanation of pseudo-static: Pseudo-static is relative to real static. Usually, in order to enhance the friendliness of search engines, we generate static pages for article content, but some friends want to display some information in real time. Or you may want to use dynamic scripts to solve some problems. Website content cannot be displayed in a static way. But this will lose the friendliness to search engines. How to find a middle ground between the two? This is where pseudo-static technology comes into play. It is displayed in the form of a static page such as HTML, but is actually processed using a dynamic script such as ASP.

First, configure the server module in Nginx as follows:

location / {
  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;
      }
  }

After the configuration is complete, restart Nginx

Then, in the "Settings" - "Permanent Links" of the WordPress blog background, customize the structure (my setting is: /%category%/%post_id%.html, that is: category/article id.html), as shown in the figure:

At this point, the pseudo-static setting of the WordPress blog is completed.

Here is a brief introduction to the fixed link setting parameters:

1. %year% is based on the year the article was published, such as 2007;
2. %monthnum% is based on the month the article was published, such as 05;
3. %day% is based on the day the article was published, such as 28;
4. %hour% is based on the number of hours the article was published, such as 15;
5. %minute% is based on the number of minutes the article was published, such as 43
6. %second% is based on the number of seconds after the article was published, such as 33
7. %postname% is based on the postname of the article. Its value is the abbreviation specified when writing. If no abbreviation is specified, it is the article title.
8. %post_id% is based on the article post_id, such as 423;
9. %category% Based on the article category, the subcategory will be processed into the form of "category/subcategory";
10. %author% is based on the article author's name.

By combining the above parameters, you can get the fixed link form of WordPress. Several common settings methods on the Internet:
/%year%/%monthnum%/%day%/%postname%/
/%year%/%monthnum%/%postname%/
/%year%/%monthnum%/%day%/%postname%.html
/%year%/%monthnum%/%postname%.html
/%category%/%postname%.html
/%category%/%post_id%
/%postname%.html
/%post_id%.html We generally prefer this method.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Six steps to teach you how to build a personal blog based on WordPress from scratch
  • Detailed explanation of the whole process of building a personal blog with nginx+WordPress
  • Detailed steps for setting up host Nginx + Docker WordPress Mysql
  • Detailed explanation of WordPress multi-site configuration under Nginx environment
  • How to configure wordpress with nginx
  • Detailed graphic tutorial on how to solve the slow access problem of WordPress website

<<:  MySQL SQL statement method to hide the middle four digits of the mobile phone number

>>:  Notes on using $refs in Vue instances

Recommend

6 inheritance methods of JS advanced ES6

Table of contents 1. Prototype chain inheritance ...

Detailed process of using Vscode combined with docker for development

Preface Using Docker and VS Code can optimize the...

Nginx configuration 80 port access 8080 and project name address method analysis

Tomcat accesses the project, usually ip + port + ...

MySQL 8.0.22 winx64 installation and configuration graphic tutorial

mysql 8.0.22 winx64 installation and configuratio...

12 Laws of Web Design for Clean Code [Graphic]

Beautiful code is the foundation of a beautiful we...

How to use firewall iptables strategy to forward ports on Linux servers

Forwarding between two different servers Enable p...

JS Easy to understand Function and Constructor

Table of contents 1. Overview 1.1 Creating a func...

A brief understanding of MySQL SELECT execution order

The complete syntax of the SELECT statement is: (...

Bootstrap 3.0 study notes for beginners

As the first article of this study note, we will ...

A brief discussion on the efficiency of MySQL subquery union and in

Recent product testing found a problem that when ...

Markup language - simplified tags

Click here to return to the 123WORDPRESS.COM HTML ...

JS canvas realizes the functions of drawing board and signature board

This article shares the specific code of JS canva...

Detailed explanation of HTML page header code example

Knowledge point 1: Set the base URL of the web pa...

How to install grafana and add influxdb monitoring under Linux

Install grafana. The official website provides an...