我通常指我的網站上使用絕對路徑的任何資產,這樣我就不必擔心資產相對於當前文件的位置。在非根目錄中部署的絕對路徑
<!-- Using a absolute path. -->
<img src="/images/flag.png" />
<!-- Using a relative path. -->
<img src="../../../images/flag.png" />
但是,這次我需要在非根位置託管網站,例如http://my-server.com/holiday/
。
我該怎麼辦?我正在尋找一種解決方案,不需要我更改文件中的路徑。如何配置服務器(Apache)將http://my-server.com/holiday/
視爲「根」?
澄清: 我還需要http://my-server.com/
表現得 「正常」。也就是說,它應該仍然指向http://my-server.com/index.html
,即不會被重定向到http://my-server.com/holiday/
。
我需要將這個.htaccess文件放在'http:// my-server.com /'或'http:// my-server.com/holiday /'上嗎? – moey
到您想要重定向的地方 - 'http:// my-server.com /' –
謝謝你們!我認爲這非常接近我尋找的解決方案。但是,我仍然希望保留'http:// my-server.com /'到'http:// my-server.com/index.html'或'http://my-server.com/index .php'。 – moey