English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hey. I am trying to learn to use SSI which is Server Side Includes on a new web site.
Would anyone be able to show me examples of how it's done as well as give me some information on how to implement it ?
I have never used it before so step by step instructions or beginners tutorials would be great.
Thanks for all your help.

D

2007-03-08 15:35:00 · 3 answers · asked by MPK 1 in Computers & Internet Programming & Design

3 answers

You specifically asked about Server Side Includes, so I hope I'm not leading you in the wrong direction by writing about the PHP require() statement. A PHP require() statement will accomplish the same thing. If your web server has PHP enabled, you can give it a try.

Let's say you want a copyright line at the bottom of every page.

Put this code in the file that needs the copyright line --- in the place where the copyright line should appear:

require ('copyright.html');
?>

This file --- the file that will ultimately display the copyright line --- must have a .php extension, not an .html extension. You could call this file test.php.

Next, create the file "copyright.html". Even though this file has the .html extension, it is not a complete HTML file. It won't start or end with or have a or <BODY> tag. It will only contain the snippet of code you want to appear in place of the require() statement.<br /> <br /> Therefore, the entire content of the file would be:<br /> <br /> Copyright © 2007<br /> <br /> To see if this works, add both files to your web server. The files should be side by side --- no file should be in a folder above or below the other file. (This can change as your technique advances.)<br /> <br /> Call up test.php from your web server in your web browser. (This won't work on the files on yor local computer -- the files have to be on a web server with PHP enabled.) As the page is served to your website, the copyright line will dynamically appear. Now, when 2008 rolls around, it will be easy to make a site-wide change to your copyright line.<br /> <br /> Also, as your technique advances, you can use longer snippets of code. If you wanted the sidebar of your site to be the same on every page, you could create a snippet of the entire sidebar and call it into every page with the require() statement. </p> <p> <small> 2007-03-08 16:01:31 · <a href="#answer20070308160131">answer #1</a> · <span>answered by <u>mason00000001</u> <b>2</b></span> · <span>0<span style='color:green;'>⤊</span></span> <span>1<span style='color:red;'>⤋</span></span> </small> </p> </div> <div id="answer20070308153827" class='answer' > <!-- <b>Answer #2</b> --> <p class='answer-content' lang="en"> http://httpd.apache.org/docs/1.3/howto/ssi.html<br /> <br /> This applies to most platforms, in addition to Apache - the basics of server-side includes are typically consistent across vendors. </p> <p> <small> 2007-03-08 15:38:27 · <a href="#answer20070308153827">answer #2</a> · <span>answered by <u>Rex M</u> <b>6</b></span> · <span>1<span style='color:green;'>⤊</span></span> <span>0<span style='color:red;'>⤋</span></span> </small> </p> </div> <div id="answer20070308161616" class='answer' > <!-- <b>Answer #3</b> --> <p class='answer-content' lang="en"> for PHP it's<br /> <br /> <? include('file.php'); ?> </p> <p> <small> 2007-03-08 16:16:16 · <a href="#answer20070308161616">answer #3</a> · <span>answered by <u>Clinton G</u> <b>2</b></span> · <span>0<span style='color:green;'>⤊</span></span> <span>1<span style='color:red;'>⤋</span></span> </small> </p> </div> </div> </article> </section> <div style="background:#888;padding:8px;margin-top:16px;"> fedest.com, questions and answers </div> </body> </html>