Example of pseudo-static rules for WordPress second-level directories in LNMP environment

Source: Internet
Author: User
Tags nginx server

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.

 

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.