Implementing WordPress Pseudo-Static Rules for Subdirectories in AMH
The AMH 4.2 virtual host panel utilizes an Nginx server. After installing the AMRewrite-1.0 module, pseudo-static rules for the main domain can be enabled. However, if you wish to implement pseudo-static rules for subdomains or subdirectories, the default rules will not suffice.
For instance, if www.xiaoz.me already has pseudo-static rules configured, installing another WordPress instance or other application in a subdirectory (e.g., www.xiaoz.me/wordpress) will not inherit the default rules. New rules must be introduced to handle this.

1. Create a New Rewrite Rule
Copy the following rules and save them as wp2.conf:
location /wordpress/ {
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 (.*) /wordpress/index.php;
}
}
2. Adjust Directory Names
Note the /wordpress/ directory in the rules above. If your subdirectory is named blog, replace both instances of wordpress with blog.
3. Save the Configuration File
Place the created wp2.conf file in the server directory /usr/local/nginx/conf/rewrite/.
4. Include the Rule in the Site Configuration
Open the configuration file for your website in the /usr/local/nginx/conf/vhost/ directory (e.g., xiaoz.me.conf). Inside the server{} block, add the following line to include the new rewrite rule:
include rewrite/wp2.conf;
Save and overwrite the file. It is recommended to back up the original file first to prevent errors.
5. Restart Nginx
Finally, restart the Nginx server via the AMH panel using the command amh nginx restart.
This method is not limited to the AMH panel; it applies to any server using Nginx with the same underlying principles. Feel free to try it out. If you have questions, you can contact me via QQ: 337003006.