server { listen 80; server_name example.com; root /var/www/example.com; gzip_static on; location / { try_files $uri $uri/ /index.html; } # Attempt to load static files, if not found route to @rootfiles location ~ (.+)\.(html|json|txt|js|css|jpg|jpeg|gif|png|svg|ico|eot|otf|woff|woff2|ttf)$ { try_files $uri @rootfiles; } # Check for app route "directories" in the request uri and strip "directories" # from request, loading paths relative to root. location @rootfiles { rewrite ^/(?:foo/bar/baz|foo/bar|foo|tacos)/(.*) /$1 redirect; } }
时间: 2024-10-24 05:43:14