Include html-files in html-pages

Lise

New member
Joined
Jul 22, 2007
Messages
4
I want to include some html-code in a htmlpage. This code contains the menu. On the internet a lot of options are suggested, like:

<!--#include virtual="insertthisfile.html" --> or
<?php include("filename.html"); ?>

Both do not work however. I am a noob in this, but from the manuals and documentation I understood php is enabled so it is supposed to work?

I hope for some good advice!
 
If you pages have a .html extention then you need to search google for server side includes (ssi).

If you using all .php then this will actually work

<?php include("filename.php"); ?>

example:

If you want to include content.php inside index.php your index.php should contain <?php include("content.php"); ?>
 
For the people who struggle with the same problem: use <!--#include virtual="insertthisfile.html" --> in the html-page and place a .htaccess file in the folder where the html-pages are or in a top level folder. It should contain:

AddType text/html .html AddHandler server-parsed .html

And it works magically :).
 
Lise, doing it your way means every .html file served by the domain will be fully parsed. If there are enough .html files being parsed (as opposed to just being delivered) that could cause the server to run slower than it otherwise would

Generally the .shtml suffix is used for files you want to be parsed, so all files won't get parsed.

DirectAdmin's default httpd.conf file already knows how to parse .shtml files.

Jeff
 
The problem is that i use Hobix, a blog-generator. So far I have not been able to let it create .shtml pages in stead of html-pages where it is necessary. Just renaming them wont do the trick, because of the internal links.

Thanks for the remark though. I was not aware of any possible lag because of this. I'll keep looking for a better solution.
 
Should I take this opportunity to recommend the book Apache For Dummies? It's a great book, though it appears that it may be out of print.

Though I'd been using Apache since it became available, I still got a lot out of that book.

Note that the Amazon Link above is a direct link; I don't get any commission for it.

Jeff
 
It seems it is possible to include the html-code directly in the page after all with Hobix, without making use of the include.

Thanks for the suggestion. I must admit I know little about Apache.
 
Back
Top