Web Folder Structure
I am working on a code where all the images are referred with a preceding "/"
eg开发者_JS百科:
<img alt="" class="repositioned" src="/images/top-b-strip.jpg" />
I have a wamp server where I run the code and find that image is not coming correctly until I remove the prceeding "/" before images.
<img alt="" class="repositioned" src="images/top-b-strip.jpg" />
Can anybody explain anything I am missing here?
Putting a "/" at the start of your path denotes that it's absolutely situated at the root of your server. For instance, http://www.example.com/images/top-b-strip.jpg, where as you may actually have them as http://www.example.com/somesubaccount/images/top-b-strip.jpg.
You can read more about absolute versus relative paths at, for instance, http://www.communitymx.com/content/article.cfm?cid=230ad
/images/top-b-strip.jpg
is an absolute path, where you need to use a relative path (without the first /).
This means that images is actually a subdirectory of the directory where your html file is, while if you use the absolute path, the images folder is supposed to be a subfolder of the root directory of the file system.
精彩评论