{%hackmd /au2gfdvHR0mEjvR_NzROqA?both %} ###### tags: `技巧` [技巧] 絕對路徑與相對路徑 === [TOC] ## 絕對路徑 - 「相對路徑」就是相對於現在目錄的路徑表示法 - 因此「相對路徑」所指到的檔案或目錄,會隨著現在目錄的不同而改變。 ``` file:///c:/windows/search.html「本機C槽上的一個HTML 檔案」。 http://www.csie.nuu.edu.tw「網路上一台 WWW Server 上的一個 HTML 檔案」。 /jang/courses/n12345678「本機 WWW 根目錄下的一個目錄」。 ``` ## 相對路徑 - 「絕對路徑」指的是一個絕對的位置,並不會隨著現在目錄的改變而改變。 - 「`.`」是代表目前所在目錄 - 「`..`」是代表上層目錄,若目前已經是根目錄則依然為目前所在目錄 - 「`/`」在各個目錄名稱之間的分隔符號,若放置在路徑之前則代表根目錄 ``` text.html「表同一層目錄下的 text.html 檔案」。 ./text.html「表同一層目錄下的 text.html 檔案 」。 image/text.html「表示 image 子目錄下的 text1.gif 檔案 」。 ../index.html「表示上一層目錄下的 index.html 檔案 」。 ../html40/cover.html「表示上一層目錄下 html40 子目錄的 index.html 檔案 」。 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up