サイト内の複数の専用ルートを、同じ名前ではない特定のディレクトリにネストしたいとします。私はそれがtry_files
のために使用するパスの書き換えを行う方法を理解できません。Nginxのネストされた場所のルートリライト
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/default;
index index.html;
server_name _;
if ($bad_referer) {
return 444;
}
location/{
try_files $uri $uri/ =404;
}
location /postfixadmin/ {
access_log /var/log/nginx/postfixadmin/access.log;
error_log /var/log/nginx/postfixadmin/error.log;
root /var/www/postfixadmin/;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location ~* \.(css|js|gif|jpe?g|png|woff|woff2|ttf|eot|svg|ico)$ {
expires 168h;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
location /email/ {
#access_log /var/log/nginx/roundcube/access.log;
#error_log /var/log/nginx/roundcube/error.log;
root /var/www/roundcube/;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
location ~* \.(css|js|gif|jpe?g|png|woff|woff2|ttf|eot|svg|ico)$ {
expires 168h;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
}
私はwww.site.com/email
に移動すると、私は404
を受け、私は存在しない、それは/var/www/roundcube/email/index.php
を探しているので、それがあると仮定しています。 try_files
の前にファイルパスを書き換えるために何をする必要がありますか?
あなたはどこを見れするのnginxを伝えるために、ルートまたはエイリアスディレクティブを使用することができます。ここでは
は、作業のソリューションです。 –