1

At first I installed grav to a sub-level directory of a nginx server and it works fine: cadoankitovua.com/blog

The conf file:

server {
    listen 80;
    server_name cadoankitovua.com www.cadoankitovua.com *.cadoankitovua.com;
    root /home/grav/web/public/;

    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /blog/index.php?_url=$uri&$query_string;
    }
    location ~ \.php$ {
        include /opt/local/etc/nginx/fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
}

I, then, installed an identical copy of grav to the /text directory and tried to modify the conf file in many different ways that I know of. None works.

I have 2 questions:

  1. How do I edit the conf file to make grav work on both /blog and /text directories?

  2. In general, how do I make many (>2) installations of grav work if I install them in many sub-level directories?

Thanks in advance.

4

1 回答 1

1

我对重力一无所知,但你可以从添加一个location /text块开始:

server {
    listen 80;
    server_name cadoankitovua.com www.cadoankitovua.com *.cadoankitovua.com;
    root /home/grav/web/public;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /blog/index.php?_url=$uri&$query_string;
    }
    location /text {
        try_files $uri $uri/ /text/index.php?_url=$uri&$query_string;
    }
    location ~ \.php$ {
        include /opt/local/etc/nginx/fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
}

编辑:一般解决方案将使用带有重写语句的命名位置,例如:

location / {
    try_files $uri $uri/ @rewrite;
}
location @rewrite {
    rewrite ^(/[^/]+) $1/index.php?_url=$uri&$query_string last;
    rewrite ^ /blog/index.php?_url=$uri&$query_string last;
}
于 2017-02-15T22:56:41.823 回答