| 5:06 am on Apr 9, 2007 (gmt 0)|
Change your test.html to test.asp and then try it.
| 2:42 pm on Apr 9, 2007 (gmt 0)|
| 3:49 pm on Apr 9, 2007 (gmt 0)|
ok firstly are you testing the webpages using a webserver or are you just opening them in your browser on your local machine?
[of course the webserver can be on your local machine too]
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.
<!--#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:
| 4:08 pm on Apr 9, 2007 (gmt 0)|
I am testing this live online, not on my local machine.
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....
| 4:13 pm on Apr 9, 2007 (gmt 0)|
|however you are most likely to have to change the file name as well to: |
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.
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!
| 5:46 pm on Apr 9, 2007 (gmt 0)|
ok if you are on apache you do it differently.
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:
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
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]
| 6:06 pm on Apr 9, 2007 (gmt 0)|
I'm on Apache and use this to include stuff:
<?php require "includedfile.inc";?> using the filepath from the host page to the included file.
My server is set to parse html and htm for php as topr8 describes.
I shouldn't worry about changing names of included files, since they are seen as part of the main page, not in their own right.
| 7:30 pm on Apr 9, 2007 (gmt 0)|
penders' post is probably the most likely solution **IF** this is a linux server. .ASP, php and other languages all have valid include functions but only server-side includes (SSI) are specific to file inclusion in a page.
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.
| 7:41 pm on Apr 9, 2007 (gmt 0)|
this is a linux server and penders solution is likely the easiest except the op said:
>> don't want to change my url's
in which case he will either have to use the php include method or use the host control panel to set up .html files to allow includes
| 10:24 pm on Apr 9, 2007 (gmt 0)|
it is apache on linux.
Topr8 - I can use php include commands and my pages can still end in .html (so as not to screw up my url's)?
| 6:58 am on Apr 10, 2007 (gmt 0)|
To parse ordinary HTML for includes, no alternate language is required, no fiddling with extensions, and your URL's can remain the same. Locate the file httpd.conf on your server. Within that file you should find the addType directive for SSI's:
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
And you're good to go.
| 3:56 am on Apr 11, 2007 (gmt 0)|
It works now, thanks for all the help!
| 7:17 pm on Apr 29, 2007 (gmt 0)|
Due to the overhead for the server to evaluate every .html file for the potential SSI's, setting all .html is generally to be avoided.
I believe the preferred method is to set:
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).
| 9:16 pm on Apr 29, 2007 (gmt 0)|
That's an interesting opposition, one I used to adhere to, but every administrator I talk to says it's no longer an issue unless you're using a **really** old machine for a server. Anyone else out there think it's still "selfish" to parse all files?
selfish=as one administrator described it once, long ago
| 11:08 am on May 5, 2007 (gmt 0)|
Change your test.html to test.asp or test.shtml and then try it.