Defining root of HTML in a folder within the site root folder

后端 未结 2 1312
暖寄归人
暖寄归人 2020-12-30 08:21

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 locat

相关标签:
2条回答
  • 2020-12-30 08:22

    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.

    0 讨论(0)
  • 2020-12-30 08:27

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

    For example

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>This is an example for the <base> element</title>
            <base href="http://www.example.com/news/index.html">
        </head>
        <body>
            <p>Visit the <a href="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

    0 讨论(0)
提交回复
热议问题