Html include not working

I was hoping someone could help me figure out why my html include was not working. In a previous thread, a while ago, I was told one can include html from another file using the following syntax: <!–#include virtual=“pathToFile.html” –>

Is that I am trying to use html includes in the following, and much simpler example, but the point is that they don’t seem to be working.

I have an index.html, which has the following syntax and a live copy is up here:

<!Doctype HTML>
<html lang="en">
		<title>Red bg on no script</title>
		<!--#include virtual="include.html" -->

and the file it includes is up here and the contents of that file is:

<style type="text/css">

So when one views index.html, shouldn’t the include be included and the body’s background be set to red?

Does anyone have any ideas on how to fix this?

What programming language are you using for the include? [LEFT]<!–#include virtual=“include.html” –> ???[/LEFT]

What happens if you change the file extension to .shtml as in index.shtml

Basically, you have to be sure that your server is set up to process SSI, then you have to tell it to look for includes by using the correct file extension.

A nicer solution (IMHO) is to use PHP includes, but your pages need to have a .php extension (well, you can avoid that, but there’s not much point generally). Anyhow, try what imaginekitty suggests anyway, so you at least know what the issue is.

@kohoutek: just normal html.


I don’t know, i will try it tomorrow.

But isn’t it already looking for the correct file-extension ?
The suggestion you made applies to the file calling the include (index.html in my example) not the file to be included (include.html), right?
@ralph_m: What does IMHO mean?
wait, a file using php includes can not have a .php extension?

Wait, what? ?? If you have a php file but you call it index.html it just serves it without processing it because the server doesn’t know to process it as a php file. Same thing with SSI. It doesn’t know to use includes because you didn’t use the proper file extension. It’s just serving it as is.


Wait, what? ??

IMHO, it means In My Humble Opinion. Get with the web lingo, man! :lol: (It’s all kinda new to me, I admit. Too old for this kid talk. :slight_smile: )

wait, a file using php includes can not have a .php extension?

You can tell your server to process PHP in .html files by adding this to your .htaccess file:

AddType application/x-httpd-php .html

I was going to see if SSI works and then pop a php_info (); on him. :slight_smile:

Ultimately, above either, my suggestion would be ASP.NET MasterPages but it may not be necessary.


Me too - but you can look trendy with the help of :D[/ot]


Wait, what? ??[/Quote]

I have no idea What I meant. I think it was a confusing way to ask the second question I asked you (confirmation on which file will have the .shtml extension).

Haha. I know that feeling. I found abbreviations and emoticons for things/words ive never heard of. Idk, btw,and ttyl are enough for me.

wait, wouldn’t that prevent the server from processing PHP in .php files? Or should the line be:

AddType application/x-httpd-php .html, .php


Haha nice. Thank you for the link @TechnoBear— ill have to take a look at that!

Btw, how do you do the off topic highlight? I have seen it a few times on the forums, but never asked how to do it.

Ah. The calling file should have the special file extension. The include file can be anything, even .txt or .inc or .blah, as long as it matches the file in the include statement.

You wrap it in [ot] opening and closing tags which, AFAIK (= as far as I know :lol:) you need to type yourself - there isn’t a button.

Tomorrow was yesterday. Ahoy, ahoy?

Apologies, I had a busy weekend and I guess I went a little too off topic. Speaking on which, thank you @TechnoBear for teaching me how to highlight off-topic (parts of) posts.

Back on topic, i tried changing index.html to index.shtml and opened it again in chrome and the background was not red. So that means that the include did not work properly, right?

Here are new links to the files as I changed the extension of index.html to index.shtml (so the old links won’t work):
1.) index.shtml
2.) include.html

Sorry for keeping you, @imaginekitty waiting much longer than it should have been :blush:.

Ain’t no thing.

OK, see it does work on my server: (I made no changes except for the file names)

Is your only host? You’ll have to use a proper host to get such functionality.

I doubt they offer PHP but try making a page called test.php and make the contents of the file exactly this:

<?php php_info() ?>

Upload it and go to that page using your browser to see if it works.

it doesn’t work. Dropbox doesn’t support PHP. But if it works now on your sever then I trust that it will work on my actual server.

Once i make the changes and upload the site, if i have questions, do you mind if i PM you?

Also if and when @ralph_m is online can he or anyone else answer my question on the line to add to the .htacess file to get php parsed in .html files?
Here it is again:

wait, wouldn’t that prevent the server from processing PHP in .php files? Or should the line be:

AddType application/x-httpd-php .html .php


I don’t think you really want .html files parsed as PHP. Just because you can doesn’t mean you should. :wink:

well i just wanted to know how to do the .htacess change properly for learning sake.

But why wouldn’t i? I know that you be a dangerous questions to ask, but it seems like an okay solution.

i think a bad thing about it is that i have to change the .htacess file.
Meaning, my HTML document will be parsed as html, as html in a php document outside of the <?php ?> tags is, and the includes will be parsed as PHP— i don’t see any issues with that.

I probably shouldn’t make comments on stuff I don’t understand well enough. :lol: That line used to work for me when I had PHP on a .html page (for testing only, as I don’t do it in real life) but on my new server it doesn’t work, so so much for that. I gather different servers require different .htaccess code, but none of the ones I’ve seen work on my new server (I’ve just tested them). So now I can’t test whether not having the .php in the htaccess rule stops PHP working on .php pages or not. Sorry!