Nginx 作為 apache 反向代理,在 .htaccess 重寫時出現 404 錯誤

Nginx 作為 apache 反向代理,在 .htaccess 重寫時出現 404 錯誤

我正在嘗試使用 Nginx 作為 Apache 的反向代理來快取靜態檔案等。基本上我有一個 vBulletin 論壇,並且我使用 vBSEO 作為 SEO 代理。問題是它會為每個 URL 產生 404,除了已經存在的檔案。

答案1

您能給我們您的 nginx 設定的相關部分嗎? Atm 我們無法猜測出了什麼問題(儘管可能是:不在主機檔案中使用“localhost”,因此無法解析為 127.0.0.1、apache 的連接埠號碼錯誤、忘記新增主機標頭等)。通常,它會是這樣的:

server {
    listen       80;
    server_name  www.example.com;

    # normally some checking here for static content which exists as file 
    # like images, js, etc, with a 'break', with at the end:

    location / {
        proxy_pass         http://127.0.0.1:<portnumber apache is on>/;
        proxy_redirect     off;
        proxy_set_header   Host $host;
    }
}

答案2

嗯,我追蹤了 SEO 友善的插件(vBSEO)。它正在生成帶有 .html 擴展名的鏈接,並且 nginx 似乎已將其設定為快取。由於這些連結實際上並不存在,因此會產生 404。

相關內容