Have small clarifications,
As of my knowledge these are the relative and absolute paths,
Completely relative: <img src="kitten.png"/>
Absolute in all respects: <img src="http://www.foo.com/images/kitten.png">
What is the difference between Relative path and absolute path?
Is there any performance issues occures for using these paths?
We will get any secure for the sites ?
Is there any way to converting absolute path to relative
Imagine you have a window open on
http://www.foo.com/bar/page.html
In all of them (HTML, Javascript and CSS):In HTML and Javascript, the base_path is based on the opened window. In big javascript projects you need a
BASEPATH
orroot
variable to store the base_path occasionally. (like this)In CSS the opened url is the address of which your .css is stored or loaded, its not the same like javascript with current opened window in this case.
And for being more secure in absolute paths it is recommended to use
//
instead ofhttp://
for possible future migrations tohttps://
. In your own example, use it this way:The path with reference to root directory is called absolute. The path with reference to current directory is called relative.
One has to be calculated with respect to another URI. The other does not.
Nothing significant.
No
In really simplified terms: Working from left to right, try to match the scheme, hostname, then path segments with the URI you are trying to be relative to. Stop when you have a match.
Relative Paths
A relative path assumes that the file is on the current server. Using relative paths allows you to construct your site offline and fully test it before uploading it.
For example:
php/webct/itr/index.php
.
Absolute Paths
An absolute path refers to a file on the Internet using its full URL. Absolute paths tell the browser precisely where to go.
For example:
http://www.uvsc.edu/disted/php/webct/itr/index.php
Absolute paths are easier to use and understand. However, it is not good practice on your own website. For one thing, using relative paths allows you to construct your site offline and fully test it before uploading it. If you were to use absolute paths you would have to change your code before uploading it in order to get it to work. This would also be the case if you ever had to move your site or if you changed domain names.
Reference: http://openhighschoolcourses.org/mod/book/tool/print/index.php?id=12503
If you use the relative version on http://www.foo.com/abc your browser will look at http://www.foo.com/abc/kitten.png for the image and would get 404 - Not found.
Going Relative:
Going Absolute: