Server Side Includes with .html Extention?

Discussion in 'Programming' started by webgaya, Aug 12, 2006.

  1. #1
    Some web hosts mention Server Side Includes as
    a feature. I have couple of unanswered questions
    about it. Please help me to get it right.

    (*) Can I upload a template, mark editable regions
    and change the template (At the server) when I
    want and spread the changes across all the pages
    that used it?

    (*) Or will have to use something like PHP includes.
    The matter here is, I want to have .html extension
    (or .shtml) rather than .php.

    (*) Is there a way to have SSI with .html extension?

    webgaya
     
    webgaya, Aug 12, 2006 IP
  2. cormac

    cormac Peon

    Messages:
    3,662
    Likes Received:
    222
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First you need to make sure your host supports server side includes.

    You wouldnt use a template as the serverside include method makes it a lot easier.

    Create a page as normal but as shtml, enter the include code into the section of each page that you need such as the header, footer and sidebar.

    Using .htaccess (something else your host needs to support) place this into the file: AddHandler server-parsed .htm so when the page loads from the server it is fed as htm, you can also have it change to html

    Upload all your files and if you need to change the header, footer or side bar you edit the actual include file and upload it. The include file can be created using html code with notepad and saved as filename.inc

    Serverside include is a brilliant and easy way of creating sites - try it out with a test page to see if you like it.
     
    cormac, Aug 12, 2006 IP
  3. webgaya

    webgaya Active Member

    Messages:
    132
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Hi turfsniffer,

    Thank you for your response. It really encouraged me.
    My host provides SSI and access to .htaccess file.
    I am quite good at HTML but couldn't get it completely.

    Can you please provide a template with necessary steps.
    It will be a great reference to all of us.

    Thank you.

    webgaya.
     
    webgaya, Aug 13, 2006 IP
  4. ing

    ing Well-Known Member

    Messages:
    500
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    195
    #4
    This is what I did to get it to work..

    Added the following line to the .htaccess file..

    AddType text/x-server-parsed-html .html .htm  
    Code (markup):
    Put what I wanted to include into a txt file, and saved/uploaded it. (filename.txt)

    Added the following line where I wanted the include to show..

    <!--#include virtual="/filename.txt" -->
    Code (markup):
    That's it. Hope that helps.
    :)
     
    ing, Aug 13, 2006 IP
  5. cormac

    cormac Peon

    Messages:
    3,662
    Likes Received:
    222
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ing I personally use filename.inc and not .txt, will that still work? I just havent tried it like that.

    webgaya I am not the best at HTML but give this a shot. Open notepad and place the following code into it.

    Save the file into the root directory of your site as footer.inc

    Now open the html page that you want to add the include into such as the index page and look at the code. At the very bottom just before the body closes make sure the code is like this:

    Save it and upload. Depending on what program you are using to build your webpages you may not see the result until you upload it to your server. Dreamweaver will show the final result when you preview the page.

    So upload the html file and the footer.inc onto your host and test the results.

    Hope that makes sense ;)
     
    cormac, Aug 13, 2006 IP
  6. webgaya

    webgaya Active Member

    Messages:
    132
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Hi friends!

    I think I got it! I will get back to you
    if I get problems.

    Thank you.

    webgaya.
     
    webgaya, Aug 13, 2006 IP
  7. ing

    ing Well-Known Member

    Messages:
    500
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    195
    #7
    Turf, I've never tried filename.inc, only .txt
    I guess there's a few ways of getting the same result.

    webgaya, I'm glad you got it working.

    :)
    Ingrid
     
    ing, Aug 13, 2006 IP
  8. cormac

    cormac Peon

    Messages:
    3,662
    Likes Received:
    222
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Well its good to know that txt can work as well, cheers for the update.
     
    cormac, Aug 13, 2006 IP