我正在使用 Hostinger 共享計劃,試圖在必須位于 public_html/.well-known 檔案夾中的單個 TOML 檔案上設定 CORS 標頭。我在“.well-known”檔案夾中有一個 .htaccess 檔案,但 Apache 服務器不會處理它。
但是,如果我將“.well-known”檔案夾重命名為“well-known”(只是洗掉句點),.htaccess 檔案就可以作業,我可以為該檔案夾中的檔案設定我想要的任何標題。
在這一點上,我已經洗掉了我的整個站點并用一個非常簡單的站點替換它,以便嘗試使其作業。
當前檔案結構如下:
public_html
/.well-known
.htaccess
test.toml
/well-known
.htaccess
test.toml
index.html
索引.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Apache Header Test</title>
</head>
<body>
Apache Header Test
</body>
</html>
.htaccess(在“.well-known”和“well-known”檔案夾中相同)
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
test.toml (identical in the ".well-known" and "well-known" folders)
Apache Header Test
When I navigate to /well-known/test.toml, the response is served with the CORS header set and a content-type of "text-plain", and the toml file contents show as plain text in Chrome, which is the desired and expected behavior for both folders.
However when I navigate to /.well-known/test.toml (with the period), there is no CORS header, it shows a content-type of "application/octet-stream", and the toml file downloads instead of showing in the browser.
What exactly is happening here and how can I fix it? Thank you!
uj5u.com熱心網友回復:
在最終向 Hostinger 提出了正確的問題(感謝 MrWhite!)后,他們確認/.well-known在共享托管計劃中無法更改檔案夾。以下是我收到的官方回復:
.well-known 目錄是服務器默認目錄,這就是為什么在共享托管計劃上無法覆寫和更改它的原因,因為重要的資料/資訊存盤在那里。要在此目錄中進行有意義的更改,您需要 root 訪問權限,這僅在我們的 VPS 計劃中可用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/443686.html
標籤:apache .htaccess server shared-hosting
上一篇:為什么find_peaks()在確定波形的最高峰時不能正常作業?
下一篇:D3js組縮放
