
users who build websites with WordPressAfter setting pseudo-static rules, only the homepage is accessible, while all other pages are404 errorThis is caused by improperly configured server pseudo-static rules. This article introducesSolution for WordPress 404 errors on Baidu Cloud Virtual Host。
If you are using a VPS and have installed it onBaota PanelorLNMPone-click package, you can easily set pseudo-static rules when adding a website. However, if you are using Baidu Cloud Virtual Host BCH, the method to set pseudo-static is slightly more troublesome. Below is the method to configure WordPress pseudo-static for Baidu Cloud Virtual Host BCH; methods for other programs are similar.
Preparations
Baidu Cloud Virtual Host BCHThere are two methods to configure pseudo-static rules: one is through the app.conf file, and the other is through the bcloud_nginx_gen.conf file.
Naiba recommends using the second method, but both methods are introduced here.
app.conf
Please copy the code below and save it as an app.conf file
handlers:
- url : /
script : /index.php
script : /index.html
- rewrite_not_exist: (.*)
script: /index.php/$1
- errordoc : 404 /error/404.html
- expire : .jpg modify 10 years
- expire : .swf modify 10 years
- expire : .png modify 10 years
- expire : .gif modify 10 years
- expire : .JPG modify 10 years
- expire : .ico modify 10 yearsNote that the above rule customizes the 404 page as /error/404.html. If you want to use WordPress's default 404 page, delete this line.
The following file expire is the file expiration time, set to 10 years by default, which can be changed to 30 days.
References:Baidu Cloud Help Documentation
bcloud_nginx_user.conf
Please copy the following code and save it as bcloud_nginx_user.conf
location / { try_files $uri $uri/ /index.php?$args; } # Add trailing slash to */wp-admin requests. rewrite /wp-admin$ $scheme://$host$uri/ permanent;
Specific method
After preparing the app.conf or bcloud_nginx_user.conf file, you can start configuring the pseudo-static rules. The method is as follows:
1. Use FTP software to upload the app.conf or bcloud_nginx_user.conf file to the website root directory (upload only one of them, not both).
2. In the Baidu Cloud Virtual Host BCH control panel, find the site start/stop and click the button after Reload Site Service.
3. Go to the WordPress site settings to configure pseudo-static rules, and check the frontend effect.
At this point, thethe pseudo-static configuration for Baidu Cloud Virtual Host BCHThe configuration is complete.
Video reference:BCH Pseudo-Static Rule Configuration