【发布时间】:2021-03-25 22:13:43
【问题描述】:
我已经配置了 nginx 别名,预期的行为是每当有 https://demo-frontend.in/dl/uurl/orr 时,它应该从 /var/www/frontend_react/build/ 目录获得请求。 但它是从默认的 /var/www/frontend/public 目录中获取的。
server {
listen 80;
root /var/www/frontend/public;
index index.php index.html index.htm;
server_name demo-frontend.in;
location / {
try_files $uri $uri/ /index.php?$args;
}
location /dl {
alias /var/www/frontend_react/build/;
try_files $uri $uri/ /index.html?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
}
【问题讨论】:
-
您能否在您的问题中添加一个完整的示例 URL,以显示您所描述的行为?
-
@HolgerJust 我已经在我的问题中更新了它。
-
@HolgerJust 感谢您的解释和解决方案。现在问题已经解决了。您提供的解决方案对我有用,只是做了一些小的改动。而不是 try_files $uri $uri/index.html =404;我用 try_files $uri $uri /index.html =404; ($uri 和 /index.html 之间的空格)
标签: nginx directory routes alias