我想托管我的網站/src/index.html
所以如果您訪問我的網站https://example.com,您將看到/src/index.html(不添加/src/index.html到 url)的內容
這是目前我的檔案結構

我嘗試在我的 .htaccess 檔案中添加以下內容:
RewriteRule ^ src/index.html
這會正確重定向,但也會將鏈接到任何其他檔案(如 style.css)的所有路徑重定向到 src/index.html,從而使它們無法使用。
像下面這樣的東西會起作用,但它會將 url 更改為,example.com/src/index.html而我希望它留在example.com:
Redirect 301 /index.html /src/index.html
uj5u.com熱心網友回復:
RewriteRule ^ src/index.html
這自然會重寫一切。要僅重寫對根的請求,您需要匹配^$。
例如:
RewriteRule ^$ src/index.html [L]
uj5u.com熱心網友回復:
最簡單的方法是將您的DocumentRoot專案放在.ln -ssrcDocumentRoot
如果您希望您的專案成為頂層(如您的示例中,http://example.com/),那么您可以直接設定DocumentRoot到您的檔案夾,或者如上所述用軟鏈接src替換檔案夾。DocumentRoot
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/490498.html
