动态更改 nginx 根目录
Change nginx root directory dynamically
如何根据特定条件在不重定向的情况下动态地将 nginx 根目录更改为另一个目录?例如,如果:
$http_user_agent ~* "googlebot"
像这样
server {
...
if ($allow = no) {
set $variable "folder_1";
}
if ($allow = yes) {
set $variable "folder_2";
}
root /var/www/$variable;
...
location / {
...
}
}
如何根据特定条件在不重定向的情况下动态地将 nginx 根目录更改为另一个目录?例如,如果:
$http_user_agent ~* "googlebot"
像这样
server {
...
if ($allow = no) {
set $variable "folder_1";
}
if ($allow = yes) {
set $variable "folder_2";
}
root /var/www/$variable;
...
location / {
...
}
}