Forum Moderators: open
I've created a file called testing.html, and where I want the included content I am putting:
<!--#include file="included.html" -->
I am putting my included.html file in the root, but nothing is appearing when I pull up the testing.html page.
are there any common mistakes / anything i might be missing?
Thanks in advance..
gmac
if you are using a webserver is it IIS (eg. is it microsoft)
if the above two are correct then you can use either
<!--#include file="included.html" -->
in this case the file path must be relative, in other words in this case the file testing.html must also be in the site root.
or
<!--#include virtual="/included.html" -->
where the file testing.html can be anywhere under the root
however you are most likely to have to change the file name as well to:
testing.asp
I'll check on the server, though e3servers (where I host) says it can handle includes no problem. Apache is installed.
What does changing the extension to .asp do for me? I'm apprehensive about this for search engine reasons - don't want to change my url's on a 5 year old site....
however you are most likely to have to change the file name as well to:
testing.asp
Or change to:
testing.shtml
This is to get the web server to parse your file for server-side includes (SSI's) (ie. <!--#include...). By default, .html files are not.
[edit]
I believe .shtml is the default file extension if you are wanting to use SSI's. Changing to .asp (Active Server Pages) will also work because ASP supports these includes also (*I think that's right?*) - HOWEVER, if you are on Apache, your server may not support ASP!
first ensure that the server is set to parse .html files with the php engine
[if it isn't you can create an .htaccess file to do this easily, so there is no need to change your file names, but most hosts have a control panel where you can set something like this - if not i'll post the .htaccess code you need to use here]
then to include files using php you do this:
<?php
include "/var/www/html/mywebsitefolder/myincludefile.htm";
?>
in this case you use the filepath of the file on the server, not from your root, your host should tell you the path to your root, in the above example i have guessed that your 'root' folder is infact here
/var/www/html/mywebsitefolder/
which is only possibly where it is, most hosts will use a similiar file structure but probably not exactly that.
[sorry for the red herring re .asp, i just assumed you were on a windows server because you had used front page extensions previously, which may not have been the case]
To which I would only add,
<!--#include file="included.html" -->
Use include file if the included file is in the same directory as the .shtml.
<!--#include virtual="/some/pathto/included.html" -->
Use include virtual if the included file is in a different directory than the .shtml.
AddType text/x-server-parsed-html .shtml
You can alter this line to parse all html
AddType text/x-server-parsed-html .shtml .html .htm
or simply add another line
AddType text/x-server-parsed-html .html
then restart httpd
/etc/rc.d/init.d/httpd restart
And you're good to go.
[hoohoo.ncsa.uiuc.edu...]
I believe the preferred method is to set:
XBitHack on
Then simply chmod +x blahblah.html so that the file has the executable bit set on. Then, the server will evaluate only those files with the +x flag, in searching for SSI's (in addition to its normal .shtml behaviour of course).
selfish=as one administrator described it once, long ago