0
我有一個以example.com作爲根的conf文件。在example.com目錄中,有一個html,css,img和js文件夾。我知道這是偏離傳統的HTML目錄作爲根。我嘗試了許多不同的配置(使用基於文件類型,變量的正則表達式等),但我總是得到太多的重定向錯誤。任何人都可以幫助一個良好的配置文件這種類型的目錄結構?這是我的conf文件。導致過多重定向的Nginx配置
server {
listen 80 default_server;
listen [::]:80 default_server;
# return 301 https://$server_name$request_uri;
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
server_name www.example.com example.com;
root /var/www/www.example.com/;
index index.php index.html;
client_max_body_size 100m;
error_page 404 = error.html?error=404;
location ~ /.well-known {
allow all;
}
location/{
location ~* \.(html|php)$ {
root html/;
}
location ~* \.css$ {
root css/;
}
location ~* \.js$ {
root js/;
}
location ~* \.(png|jpeg|gif)$ {
root img/;
}
try_files $uri =404;
}
}
在此先感謝您的幫助!
我認爲它應該工作。它出什麼問題了?什麼是日誌文件? – uzsolt
我在回答中發佈了問題。它必須處理導致重定向循環的相對路徑。 – Quintin