Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
Closed Thread
Results 1 to 3 of 3

Thread: SSI Overview

  1. #1
    melkior_inactive Guest

    Default SSI Overview

    In my htaccess files tutorial I mentioned SSI and how to enable it.
    I thought I could write a short article on SSI.

    SSI or Server Side Includes are a way of adding dynamic content to otherwise static HTML files.
    Again, we're talking about Apache servers here. Please note that.

    Now, you might have seen static pages that display the time or similair things. This can be done via JavaScript but it can also be done by SSI.
    I've told you how to enable SSI now let's look at the possibilities.

    SSI directives look like HTML comments so if you don't have SSI on your site they just won't be displayed. But if you do, apache will search through the file, parse them, run them and display the output/results.

    SSI always look like this:
    HTML Code:
    <!--#tag variable=value-->
    SSI directives are always opened with <!--# and they are always closed with -->

    If you want to output a value, you would use:
    HTML Code:
    <!--#echo var="Hello"-->
    which is actually useless since it's content is static.

    But let's say that you want to print out the date:
    HTML Code:
    <!--#echo var="DATE_LOCAL"-->
    If you want to output when you last updated the file without actually keeping the track you could write something like this:
    HTML Code:
    The file was last updated on: <!--#flastmod file="index.html"-->
    That would display the date of the last modification of the index.html file.

    If you want to use the same header on all your html files and you want to avoid using frames you could do this:
    HTML Code:
    <!--#include virtual="/header.html" -->
    You could do the same for the footer, or a menu.

    Another side to SSI is running commands on the server. This is also the dangerous part. It's a great opportunity for hackers to run commands on your server. So you'll want to be careful.

    There's also a difference if your apache server is running on Linux or on Windows since the commands aren't the same.
    Let's say you want to display the output of the DIR command (the directory listing)
    On Windows it would be:
    HTML Code:
    <pre>
    <!--#exec cmd="dir" -->
    </pre>
    But most servers are running Linux so that should be:
    HTML Code:
    <pre>
    <!--#exec cmd="ls" -->
    </pre>
    I'll give you some more examples tomorrow.

  2. #2
    temi's Avatar
    temi is offline Facilitator temi is just really nice temi is just really nice temi is just really nice temi is just really nice temi is just really nice
    Join Date
    Jun 2003
    Location
    London, England.
    Posts
    10,304

    Default

    Looking good Melky

    * Build a shopping cart for your business with eCommerce software UK
    * BossCart.com can build you a.
    Register your domain names at Velnet
    ::
    Add Eco sites to The Green Directory free of charge.
    Use LBS Free PHP Directory Script . Web Hosting Blog

  3. #3
    melkior_inactive Guest

    Default

    Let's say you want to display the IP adress of the user browsing your site.
    You can do that by writing this in your code:
    HTML Code:
    <!--#echo var="REMOTE_ADDR"-->
    You can also include the output of CGI scripts in your cgi-bin directory like this:
    HTML Code:
    <!--#exec cgi="/cgi-bin/script.cgi" -->
    That would execute the script called script.cgi located in your cgi-bin directory and it would print out the script's output in the page.
    Usually used for visit counters or click counters.

    If you want to link to the referrer page add this code:
    HTML Code:
    <a href="<!--#echo var="HTTP_REFERER"-->">Referrer page</a>
    And finally the conditionals or the IF statement.
    It is usually used to determine user's browser and serve different versions of the page customized for the browser.
    It looks like this:
    HTML Code:
    <!--#config timefmt="%A"-->
    <!--#if expr="$date_gmt = Friday" -->
    Friday today, tomorrow's weekend.
    <!--#elif expr="($date_gmt = Saturday) || ($date_gmt = Sunday)" -->
    Weekend finally!
    <!--#else -->
    Another work day...
    <!--#endif -->
    The first line of the code defines that the date should display the day of the week.
    The rest of the lines compare the date to the set parameters and display text accordingly.

    Well, that's about it. This was a short overview and a few examples included.
    Hope you liked it.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Google Pack Overview
    By melkior_inactive in forum In The News
    Replies: 2
    Last Post: 03-23-2007, 03:20 PM

Bookmarks

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124