Skip to content Skip to sidebar Skip to footer

Defining Root Of Html In A Folder Within The Site Root Folder

I want to have a new folder containing a set of new html files. All the images inside it are in the format src='image.png' and image.png is located in the root folder. But when you

Solution 1:

Use the <base> element. It allows you to specify a URL for all relative URLs in a page.

For example

<!DOCTYPE html><html><head><metacharset="utf-8"><title>This is an example for the <base> element</title><basehref="http://www.example.com/news/index.html"></head><body><p>Visit the <ahref="archives.html">archives</a>.</p></body></html>

The link in the this example would be a link to "http://www.example.com/news/archives.html".

For you, the base URL may be something as simple as <base href="http://www.yoursite.com/">. This would make images specificed as src="image.png" resolve as "http://www.yoursite.com/image.png"

See also https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

Solution 2:

You need to set the base tag. If you add the tag in your page <head> like this:

<base href="http://yoursite.tld/folder/">

it should display images and with sources relative to this base path.

Post a Comment for "Defining Root Of Html In A Folder Within The Site Root Folder"