I am creating a website on localhost
. I want to make all of link resources in my website to relative path ( I mean only internal resources).
website is located in
http://localhost/mywebsite
I read this useful question Absolute vs relative URLs.
I found differences between /images/example.png
and images/example.png
<a href="/images/example.png"> Link To Image</a>
Above relative path should return ROOT_DOCUMENT/images/example.png
because of /
at first of url. As ROOT_DOCUMENT
is something like /wamp/www/mywebsite
But when I tested it, it only return /wamp/www/images/example.png
And I should add manually my website folder /mywebsite/images/example.png
to relative path.
<a href="mywebsite/images/example.png"> Link To Image</a>
And it is not useful because of changing the name of mywebsite. So:
- Why does this problem occur?
- How can I resolve this problem?
/
then that's not a relative path...that's site-root. – Indebtedness