Generally, the website is placed in the root directory, but sometimes some sub-sites are put in the second-level Directory. For LNMP or other Nginx environments, if you place the Wordpress site in the second-level directory, you need to configure a dedicated second-level directory pseudo static rule for Wordpress.
Open nginx. conf or the configuration environment of a site (for example, duoluodeyu.com. conf), and add the following code in the braces of server {} to add the Wordpress pseudo-static rule to the son Directory of the Level 2 Directory:
Location/son /{
Try_files $ uri // son/index. php? $ Args;
}
Note: replace son in the code with your second-level Directory.
After Nginx or LNMP is restarted, the new pseudo-static rules will take effect. The Wordpress site in the second-level directory can normally customize pseudo-static rules.
Additional reading:
When the Wordpress site is placed under the root directory, the pseudo static rules of the Nginx server officially provided by Wordress are:
Location /{
Try_files $ uri // index. php? $ Args;
}
Example
For the local FTP software, find the "/usr/local/nginx/conf/wordpress. conf" file on your host and add the following content:
Location/111cn.net /{
Index index.html index. php;
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 (. *)/111cn.net/index.php;
}
}
Note: In the above code, the 111cn.net directory should be changed to the name of the second-level directory folder on your website.
Restart lnmp and the website becomes normal.