I have a base url that as far as I can tell works for any link that has code like href="...
but does not work with files that are called by the include
command.
<base href="http://.../www/" target="_blank">
For example, suppose I am one directory down from the directory specified by the base url. The base directory contains, say, helper.css
and a folder called includes
that has a file sidebmenu.htm
. The code on the page that is one directory down
`<link href="helper.css" media="screen" rel="stylesheet" type="text/css">`
will load helper.css
. Likewise, any links to other pages inside the base directory and any sub folders are correctly called on.
However,
<!--#include file="includes/sidemenu.htm"-->
will not work unless I use ../
to go up one directory
<!--#include file="../includes/sidemenu.htm"-->
and then it will work.
Is there something similar to <base>
that will make the paths to files called on by include
relative to the same base directory?
<--!#include
is a server side include. That means that the server already imports the HTML and returns the combined files as one response. The paths there are not urls but actual file paths (that is, if you use the file
attribute like you do) to html template files on the server. So you could possibly even include files from outside the document root, that is, if your server allows it (apparently Apache does not).
The <base>
tag is to set a base url for subsequent requests by the browser, for instance image urls and css files.
As a side note, maybe you are interested in HTML5 client side includes. This is a different method, no drop in replacement for SSI, and browser support is very poor atm. Interesting reading material, though. ;)