私は以下を欲しいです。 http://some.site/person1/some/path/home/person1/some/path
にアクセスする(及びhttp://some.site/person1は/home/person1/index.html
にアクセス)とhttp://some.site/person2/some/pathは/home/person2/some/path
にアクセスしなければならない(及びhttp://some.site/person2は/home/person2/index.html
にアクセスする)べきです。 personX
が多数あります。 nginxにすべてを見つける場所を伝えるには、正規表現を使用することが重要です。nginx:ルートに基づいて選択されたルート
私は、動作するルート、リライトディレクティブのセットを試してみました。私が一番近かったのは私のsites-available/website
でした。
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /some/default/root;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri.html $uri $uri/ =404;
}
location /person1 {
root /home/person1;
rewrite ^/person1(.*)$ $1 break;
}
}
これは、フォームhttp://some.site/person1以外のすべてのパスで必要なものです。この場合、nginxは私が望むように/home/person1/index.html
にアクセスしません。代わりに、正規表現は、nginxが好きではない空の文字列を返します(nginx/error.logに苦情があります)。