I am using html base tag in head but not working very well.
This is my folder structure.
- BaseWebsite (Folder)
- - Root (Folder)
- - default.html
- - css (Folder)
- - js (Folder)
- - image (Folder)
in IIS, i create a new web site pointing to BaseWebsite
and made Root
an application.
This is my code in default.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/site.css" />
<script language="javascript" src="js/site.js" type="text/javascript"></script>
</head>
<body>
<img src="image/site.jpg" />
.
.
.
</body>
</html>
When I run the page, css is there with the href="Root/css/site.css"
but js and image are missing with the src starting js/site.js
and image/site.jpg
So I put this after <head>
<base href="/Root/" />
Now, both js and image are showing but css is not showing as the href becomes href="/Root/Root/css/site.css"
Is it normal or how do I solve this? I can solve it by change href of css to /Root/css/site.css
but there are a lot of places to change.
In a base
element, the href
attribute must be an absolute URL, such as http://www.example.com/foo/bar/
. A URL that begins with /
(or .
) is relative.
You need to fix the absolute URL or use some other technique, such as a server-side programming tool or a preprocessor.