tags:

views:

64

answers:

3

I'm just trying to do a simple include statement in HTML. I have no clue why its not working. My file setup is basically index.php in the root and then a file called "includes" with a file "header.html" inside. So here's my code:

<!DOCTYPE html>
<html lang="en">
<html>
<head>
 <title>Title</title>
<link type="text/css" href="style/style.css" media="screen" rel="stylesheet">
<script src="scripts/jquery.js" type="text/javascript"></script>
<script src="scripts/code.js" type="text/javascript"></script>

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="wrapper">

    <!--#include virtual="/includes/header.html" -->

...blah blah blah
</div>  

</body>
</html>

I've verified that the file is there so I'm not sure what else the problem could be. Thanks!

+4  A: 

HTML doesn't have a simple include mechanism (except frames, but they have side effects).

What you have there is a Server Side Include, and it requires support from your web server. Most web servers support SSI, but the functionality might not be enabled (and usually isn't for .html files as the overhead for processing static files is not worth it).

Servers don't process PHP output for SSI (although it is theoretically possible) and they don't process files that PHP is reading in (i.e. with a PHP include). Use PHP includes all the way down the chain instead.

David Dorward
+2  A: 

Does your server have SSI (Server Side Includes) enabled? That's what you're trying to use, but it has to be turned on within your web server's configuration to work.

Also, since you're making it a PHP file, you might just want to use PHP's include instead:

<?php include("path/to/file"); ?>
Amber
A: 

Try it like this:

<?php include("/includes/header.html"); ?>

The syntax you're using is called server-side includes and has to be enabled in your web server settings

dreeves