nginxstylesheetuserfrosting

UserFrosting Nginx asset-raw 404


I am using Nginx and I am not using Apache. So I need a piece of Nginx code to solve the loading problem of the front-end static resources.

My problem is similar to this, but I am not Apache. I didn't find what I wanted in the 'webserver-configs' folder.

The following code does not seem to work.

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;
}

Solution

  • The following Nginx rule configuration code can correctly solve the above problem.

    āœ” After my actual test.

      ## 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