不同服務(wù)器軟件的默認(rèn)根目錄存在差異:
/var/www/html
或/srv/http
/usr/share/nginx/html
C:\inetpub\wwwroot
虛擬主機(jī)場景下需通過配置指定自定義路徑。
通過解析服務(wù)器配置文件可準(zhǔn)確獲取根目錄:
httpd.conf
中查找DocumentRoot
參數(shù)nginx.conf
內(nèi)定位root
指令.htaccess
文件中的重定向規(guī)則容器化部署時(shí)需注意環(huán)境變量$WEB_ROOT
的覆蓋規(guī)則。
現(xiàn)代框架常采用二級目錄結(jié)構(gòu):
wp-content
獨(dú)立存儲用戶數(shù)據(jù)public
為對外目錄build
輸出路徑此時(shí)實(shí)際根目錄可能包含index.php
的路由轉(zhuǎn)發(fā)邏輯。
可通過以下方式確認(rèn)正確性:
test.html
并嘗試通過URL訪問phpinfo
查看$_SERVER['DOCUMENT_ROOT']
錯(cuò)誤配置會導(dǎo)致404響應(yīng)或權(quán)限校驗(yàn)失敗。
2025-03-13
廣州蘇營貿(mào)易有限公司專注海外推廣十年,是谷歌推廣.Facebook廣告核心全球合作伙伴,我們精英化的技術(shù)團(tuán)隊(duì)為企業(yè)提供谷歌海外推廣+外貿(mào)網(wǎng)站建設(shè)+網(wǎng)站維護(hù)運(yùn)營+Google SEO優(yōu)化+社交營銷為您提供一站式海外營銷服務(wù)。
We and selected third parties use cookies or similar technologies for technical purposes and, with your consent, for other purposes as specified in the cookie policy.
You can consent to the use of such technologies by closing this notice, by interacting with any link or button outside of this notice or by continuing to browse otherwise.