SSI in HTML - how best to do this?

Status
Not open for further replies.

atomman

New Member
Messages
22
Reaction score
0
Points
0
I need to include text (html) files in *.html documents, such as...

<!--#include file="/ThisFile.inc" -->

The problem is that i have over 100 documents on my website and do not want to change the extensions or do redirects. It appears there's several ways of accomplishing this, but i'd like advice on the best way.

I tried CHMOD 744, but that didn't work :)
 

Russ

<b>Retired *****</b>
Messages
3,168
Reaction score
2
Points
38
Don't use ssi.. Use php for this. It works better, and you can include any type of file., .php, .html, .htm etc..

<?php include("file.php/.html/.htm"); ?>



Benefits of PHP Include

1. Update different parts of your site from one file.

2. Include content from other web sites outside your server
(not possible with SSI).

3. No need to create a .htaccess file (needed for SSI).

4. Able to keep the .php extension without renaming it to
some other extension (like *.shtml).

5. You can include files with .php, .html, .asp, .txt and
other extensions.

6. Faster than SSI (server side includes) , and uses less
CPU resources than SSI.

7. Create article or news feeds if the PHP version on
your server supports the function.
 
Last edited:

atomman

New Member
Messages
22
Reaction score
0
Points
0
thanks for the very good info!

Problem is, my files currently use the .html extension. I don't really have a big problem with changing them, but i would absolutely have to find a way to deal with broken links. The change would have to be transparent for search engine bots and visitors. What would i need to do?
 

sonicsshadow

Member
Messages
200
Reaction score
0
Points
16
If you have file.html, change it to file.php and then make a file.html file redirect to the homepage or something, or make a 404 redirect directly to the homepage or something.
 

Russ

<b>Retired *****</b>
Messages
3,168
Reaction score
2
Points
38
This is what I used to do.. (It's been a while since I used php, so if this is wrong someone correct me..)

I'd make my index page index.php, this is what the user sees.. I'd include everything in this, text on it and all.. Then, make a template file (I usually call them loader.php) where it has navigation on the left side of the screen, site heading/image at the top and the center beside navigation i'd have this:

<?php include("$file.html"); ?>

And, then for the navigation have all the links on the site point to something like this, say you had a html file called contact.html, you'd link to
<a href="loader.php?file=contact">Contact Us</a> This would, when a user clicks on it, load the contact.html file inside of the php page, thus doing this creates smaller pages, as the html files dont all have to have the header tags, site background info and all that, it's all in one template file. This also makes it easier to change the entire site design by just changing one file.. I believe that above works.. I would have to try to to make sure.
 
Last edited:

phnord

New Member
Messages
17
Reaction score
0
Points
0
This is what I used to do.. (It's been a while since I used php, so if this is wrong someone correct me..)

I'd make my index page index.php, this is what the user sees.. I'd include everything in this, text on it and all.. Then, make a template file (I usually call them loader.php) where it has navigation on the left side of the screen, site heading/image at the top and the center beside navigation i'd have this:

<?php include("$file.html"); ?>

And, then for the navigation have all the links on the site point to something like this, say you had a html file called contact.html, you'd link to
<a href="loader.php?file=contact">Contact Us</a> This would, when a user clicks on it, load the contact.html file inside of the php page, thus doing this creates smaller pages, as the html files dont all have to have the header tags, site background info and all that, it's all in one template file. This also makes it easier to change the entire site design by just changing one file.. I believe that above works.. I would have to try to to make sure.

I have to warn you that this code is very dangerous. Not only does it generate errors if the "file=" in the url is not found, but it leaves the server wide-open for a directory transversal.
 

Doc Photoshop

New Member
Messages
41
Reaction score
0
Points
0
This is something that I have been looking at too, mainly for multilingual sites. Is there any guide to this about that anyone could recommend? Basically "An idiots guide to PHP includes?"
 
Messages
341
Reaction score
0
Points
0
There Is "PHP For Dummies" I Would Reccomend "PHP For The Absolute Beginer" And rpope904's method wont work because x10 has register_globals disabled
 

Doc Photoshop

New Member
Messages
41
Reaction score
0
Points
0
There Is "PHP For Dummies" I Would Reccomend "PHP For The Absolute Beginer" And rpope904's method wont work because x10 has register_globals disabled

Thanks for the recommendations, I will snag a copy of them when I am back in England at the end of this week. (Tech manuals hurt my head, especially when written in Spanish!)

As for putting them on a server, it is not my intention just yet, I just want to know how to do it, because I am wanting to add more tools to the design and construction box of tricks. For my usual method of SSI, I just seem to be happy plodding away with iFrame content, or just the standard include method mentioned above; because the PHP thing had passed me by a little.
 
Status
Not open for further replies.
Top