how to not use relative links in html, but everytime starting from the domain

I’m trying to make a page for use with wordpress and it’s almost working,
The page I want to use is an HTML page with designated space for it within certain DIVs.

I’m encountering the problem of wordpress using the wrong links to kind of everything. I will probably have to change every link to http://www.mydomain.com/sub/folder/image.jpg while there are many links.
the page is positioned in a subfolder, there where wordpress is installed on the server.

Read More

But other pages are positioned in the root, and retrieve all other files directly starting from the domain so writing /sub/folder/image.jpg is enough.
Is there a way I could get this to work with html/php files in sub folders as well (so when typing a link like /sub/folder/image.jpg they retrieve http://www.mydomain.com/sub/folder/image.jpg
and not
http://www.mydomain.com/sub/folder/sub/folder/image.jpg

thanks!

Related posts

Leave a Reply

2 comments

  1. Every link starting with a slash / is absolute, meaning starting from the domain name.

    If you omit the slash, then the path is relative and is appended to the current location.

  2. If you are using URLs such as sub/folder/image.jpg with no slash at the beginning (i.e. relative URLs), the browser should add this to the current folder.

    Which means that if the current document is :

    http://www.mydomain.com/sub/folder/my-page.html
    

    You should end up with this :

    http://www.mydomain.com/sub/folder/sub/folder/image.jpg
    

    But if you use URLs such as /sub/folder/image.jpg with a slash at the beginning (i.e. absolute URLs), the browser should start from the domain-name.

    Which means that, with the same URL for your HTML document, you’d end up with this :

    http://www.mydomain.com/sub/folder/image.jpg