Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Server Side Includes

  1. #1
    Join Date
    Dec 2010
    Posts
    9

    Default Server Side Includes

    Although this subject is discussed in a few places, I have not been able to get the whole picture somehow.
    Some of the suggestions indicate an addition to the apache settings.
    As far as I can see, the apache settings show that it accepts an shtml file(which is what I am using as my include file extension)
    I have placed my include files in a separate subfolder and coded the main html file as follows:
    (Should the file extensions described above perhaps be reversed?)
    <!--#include virtual="/includes/xyz.shtml" -->
    Nothing is working.
    One question: Why must these lines be commented out? Surely they should not be.(I know this is a stupid question but I am desperate)
    I know that I am not getting the full picture here. Can someone fill in the gaps in my understanding please.
    Many thanks for that.

  2. #2
    Join Date
    Apr 2008
    Location
    Morgan Hill, CA
    Posts
    882

    Default

    The HTML file with the "#include" in it needs the .shtml extension. The included file can have, as far as I know, any extension that you'd like.

    Do you have the line:
    Code:
    Options +Includes
    in your .htaccess file for that folder?

    The comment marks perform two functions:

    1. They identify the line as an 'include' directive. You can think of the "<!--" as part of the "#include".

    2. They prevent the actual text of the line from being shown by the browser if the file doesn't get included for some reason.

    <added>
    If I'm recalling things correctly, you can use the .html extension for your pages with includes if you add the line:
    Code:
    AddHandler server-parsed .html
    to your .htaccess file for that folder.
    </added>
    Last edited by Bob Barr; 05-01-2011 at 08:34 AM.

  3. #3
    Join Date
    Dec 2010
    Posts
    9

    Default

    Thanks Bob.
    I think I have tried everything I have read, here and in other posts, without obvious success yet.
    I have tried the includes in a subfolder, with ./subfolder/file, /subfolder/file, and subfolder/file reference options.
    I have a .htaccess file in the main folder which contains the .shtml calling file.
    (Contents:

    # Use PHP5 Single php.ini as default
    AddHandler application/x-httpd-php5s .php
    Options +Includes
    AddHandler server-parsed .html)

    I have tried naming the includes .html and .shtml.
    I have tried a .htaccess file in the includes subfolder.
    I have tried "AddType text/html shtml" in the .htaccess file.(from apache website)

    I am in a test process at the moment in preparation to setting up my site so fortunately there is no pressure right now.

    I realise also, or think so, that this is probably the most difficult part of my setup process.

    My site is however very dependant on includes to simplify updates.

    I'm still doing something obvious wrong.

    I just at present don't know what it is yet.

    Any obvious answers from out there?

    Many thanks for your assistance.

  4. #4
    Join Date
    Nov 2006
    Location
    Sydney, Australia
    Posts
    4,951

    Default

    Do the pages that have the includes have a .shtml extension?

  5. #5
    Join Date
    Dec 2010
    Posts
    9

    Default

    Hi Stephen.
    Yes.
    I am trying an index.shtml file with two include files to try and get the system to work.
    I am finding other subfolders from the index file so the folder system is working.
    I know the answer is going to be something obvious I have missed.(sigh!)
    Anyone see any obvious omissions everyone else would have remembered?
    Many thanks anyway.

  6. #6
    Join Date
    Dec 2010
    Posts
    9

    Default

    Hi all.
    Just one more thought.
    I am testing these files in a subdirectory of a site on which I am running a Wordpress blog.
    Would this make a difference?
    Would the installation of the Wordpress software perhaps have made certain setttings which are preventing me using the Server Side Includes?

  7. #7
    Join Date
    Jan 2010
    Location
    Antipodes
    Posts
    77

    Default

    Quote Originally Posted by odbinfo View Post
    Thanks Bob.
    I have tried "AddType text/html shtml" in the .htaccess file.(from apache website)
    It's probably not it, but from the Apache website, there is a stop in front of the file extension --> .shtml not shtml

    i.e. "AddType text/html .shtml"

    Have you tried the XBitHack? - this has worked for me on bluehost

  8. #8
    Join Date
    Feb 2006
    Location
    Florida, USA
    Posts
    1,505

    Default

    Give us a link to your shtml file.

    And if I might inquire, is there a reason you're using SSI instead of PHP?

    I only ask because time spent trying to learn SSI may be better spent learning PHP, as it's fairly widely supported and can do far more than SSI can.
    If at first you don't succeed, try reading the instructions.
    semlar.com

  9. #9
    Join Date
    May 2011
    Posts
    1

    Default

    Configuring your server to permit SSI
    To permit SSI on your server, you must have mod_include installed and enabled. Additionally, you must have the following directive either in your httpd.conf file, or in a .htaccess file:
    Options +Includes
    Not just any file is parsed for SSI directives. You have to tell Apache which files should be parsed. There are two ways to do this. You can tell Apache to parse any file with a particular file extension, such as .shtml, with the following directives:
    AddType text/html .shtml
    AddHandler server-parsed .shtml
    One disadvantage to this approach is that if you wanted to add SSI directives to an existing page, you would have to change the name of that page, and all links to that page, in order to give it a .shtml extension, so that those directives would be executed.

  10. #10
    Join Date
    Dec 2010
    Posts
    9

    Default

    I seem to have got it working.
    Thanks to all who made suggestions.
    I think it was mostly following all the instructions properly.
    My testing method was also suspect.


    Why is it that the dominant file needs to be an .shtml file?
    Can it not be .html?
    As stated above, I will have to change all my files and the links. A major job.

    Basil:
    I am not very bright at much more than very simple code.
    Could you very briefly indicate how to use php as an alternative? Or point me to examples.
    Thanks again to everyone. I really appreciate it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •