UserFrosting Nginx资产原始404

时间:2019-05-12 12:14:57

标签: nginx stylesheet userfrosting

我正在使用Nginx,而我没有使用Apache。 因此,我需要一段Nginx代码来解决前端静态资源的加载问题。

我的问题类似于this,但我不是Apache。 在“ webserver-configs”文件夹中找不到我想要的东西。

以下代码似乎无效。

location ~* \.(png|gif|jpg|jpeg|svg|ico|css|js|woff|ttf|otf|woff2|eot)$ {
  index index.php;
  try_files $uri $uri/member/public/asset-raw/ member/public/index.php?$query_string;
}

1 个答案:

答案 0 :(得分:0)

以下Nginx规则配置代码可以正确解决上述问题。

✔经过实际测试。

  ## Begin - UserFrosting Caching static files
  location ~* \/member\/.*\.(png|gif|jpg|jpeg|svg|ico|css|js|woff|ttf|otf|woff2|eot|json)$ {
    index index.php;
    try_files $uri $uri/ /member/public/index.php?$query_string;
  }
  ## End - UserFrosting Caching static files

  ## Begin - Index
  ## for subfolders, simply adjust:
  ## `location /subfolder {`
  ## and the rewrite to use `/subfolder/index.php`
  location /member/public/ {
    index index.php;
    try_files $uri $uri/ /member/public/index.php?$query_string;
  }
  ## End - Index