Nginx

Nginx - 從子文件夾提供靜態網站

  • June 30, 2022

我在網站的子文件夾中有一個靜態應用程序:

URL: https://example.com/application

Files:
/home/username/web/application/public/index.html
/home/username/web/application/public/css/style.css
...

如何設置正確的“位置”以訪問文件public夾下的靜態文件?

我試過沒有成功:

location /application/ {
      /home/username/web/application/public;
      index index.html;
}
location ^/application/(.*)$ {
      alias /home/username/web/application/public/$1;
      index index.html;
}

嘗試這個

location /application {
  alias /home/username/web/application/public;
  index index.html; 
}

引用自:https://serverfault.com/questions/1104468