Generally, we will install the website program in the root directory of the site, so that when we use the pseudo static rules, we can directly call the default configuration file. However, sometimes we need to install the website program to the secondary directory (an independent folder under the root directory), so that we can achieve the effect of a secondary directory/subdirectory independent channel site.
Among them, Lao Zuo shared it in his early days“ Resolve the pseudo static problem of the LNMP (Nginx) secondary directory wordpress website "Today, we encountered the need to install Typecho programs in subdirectories. Here we share two possible pseudo static rules under Typecho Nginx system as follows.
First, root directory Typecho rules
location / {
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 (.*) /index.php;
}
}
Second, subdirectory pseudo static rules
Location/subdirectory folder/{
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php last;
}
if (!-f $request_filename){
Rewrite (. *)/subdirectory folder/index.php last;
}
}
If we have two TYPEHO or other programs in the same site, whoever is in the subdirectory will throw the rules of the subdirectory into the configuration file. Note that the name of the subdirectory folder needs to be modified.
Finally, restart Nginx to check whether an error is reported. If no error is reported, there should be no problem.
Scan the code to follow the official account
Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge