根 ( http://www.example.com/ ) 将指向 /var/www/wordpress
我怎样才能让每个人都可以在浏览器中查看?
working -- http://www.example.com
error -- http://www.example.com/wordpress2
error -- http://www.example.com/htmlsite
Run Code Online (Sandbox Code Playgroud)
这是结构:
first wordpress: /var/www/wordpress
second wordpress: /var/www/wordpress2
static html page: /var/www/htmlsite
server {
root /var/www/wordpress;
index index.php;
...
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /wordpress2 {
root /var/www/wordpress2;
try_files $uri $uri/ /index.php$is_args$args;
}
location /htmlsite {
root /var/www/htmlsite;
try_files $uri $uri/ =404;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我这样做root /var/www;
,那么 /wordpress2 和 /wordpress3 可以工作:
server {
root /var/www;
index index.php;
...
location / {
try_files $uri $uri/ =404;
}
location /wordpress2 {
try_files $uri $uri/ /wordpress2/index.php$is_args$args;
}
location /wordpress3 {
try_files $uri $uri/ /wordpress3/index.php$is_args$args;
}
location /htmlsite {
root /var/www/htmlsite;
try_files $uri $uri/ =404;
}
}
Run Code Online (Sandbox Code Playgroud)
这应该按照您想要的方式工作。
由于 URI 附加到root
指令中指定的目录,我们只需要指定一次。只需为每个位置分别指定`try_files'。
server {
root /var/www/wordpress;
index index.php;
...
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /wordpress2 {
root /var/www;
try_files $uri $uri/ /wordpress2/index.php$is_args$args;
}
location /htmlsite {
root /var/www;
try_files $uri $uri/ =404;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
30293 次 |
最近记录: |