diff --git a/config/nginx.conf.template b/config/nginx.conf.template index 76521d5..386a13a 100644 --- a/config/nginx.conf.template +++ b/config/nginx.conf.template @@ -17,7 +17,23 @@ http { index index.php index.html index.htm; location / { - try_files $uri $uri/ /index.php?$query_string; + # Try global root first, fallback to @project_fallback if not found + error_page 404 = @project_fallback; + try_files $uri $uri/ =404; + } + + # Handle root-relative asset requests from project folders + location @project_fallback { + # Skip for common non-project paths + if ($uri ~* ^/(favicon\.ico|phpmyadmin|admin)) { + return 404; + } + # Capture project slug from Referer header (e.g., http://localhost/my-project/...) + if ($http_referer ~* "^https?://[^/]+/([^/]+)/") { + set $proj_slug $1; + rewrite ^(.*)$ /$proj_slug$1 last; + } + return 404; } {{PROJECTS}}