精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程
  • 让你的网站产生收益赚钱,有博客和网站的绝对不能错过
  • 将指定的流量带到你的网站,为你站增加有效的访客,为你提升业绩
  • SSI技术—SHTML(静态页面最火的技术)

    来源:不详 时间:07-12-10 点击: 点击这里收藏本文
    什么是shtml SHTML语法 SHTML教程 格式 编写 技术

    使用SSI (Server Side Include)技术

    想要找到既富有创意的平面设计人员,又有脚本开发经验的人员,实在是太难了。而如果一个百分之百的页面都是php脚本的网站,将为页面维护带来非常大的困难。而且使用了php的自动加头和加尾的方法,使得几乎所有页面都是语义不完整的,不能借助任何一款页面设计工具工作,是另一个弊病。

    利用SSI技术,可以有效的将HTML网页和CGI脚本逻辑上分开,也可以将重复的HTML元素抽象和独立出来,减轻维护负担。

    SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served. They let you add dynamically generated content to an existing HTML page, without having to serve the entire page via a CGI program, or other dynamic technology.

     全文:

     配置Apache,支持SSI# This tells Apache that you want to permit files to# be parsed for SSI directives.Options +Includes
    # At linux or unix can use#  Options +Includes -IncludesNOEXEC# win32 not use it
    # You have to tell Apache which files should be parsed.AddType text/html .shtmlAddHandler server-parsed .shtml
     SSI语法 

    Basic SSI directives Syntax

    <!--#element attribute=value attribute=value ... -->
     

    Today's date

    <!--#config timefmt="%Y/%m/%d %a %H:%M:%S" -->Today is <!--#echo var="DATE_LOCAL" -->
     

    Modification date of the file

    This document last modified <!--#flastmod file="index.html" -->
     

    Including the results of a CGI program

    <!--#include virtual="/cgi-bin/counter.pl" --><!--#include virtual="/cgi-bin/example.cgi?argument=value" -->
     

    You can use "#exec cgi=" directive, but it can be disabled using the IncludesNOEXEC Option.

    Including a standard footer

    <!--#include virtual="/footer.html" -->
     

    Executing commands

    <!--#exec cmd="ls" -->
     

    This feature is dangerous. You can allow SSI, but not the exec feature, with the IncludesNOEXEC argument to the Options directive.

    Setting variables

    <!--#set var="modified" value="$LAST_MODIFIED" --><!--#set var="date" value="${DATE_LOCAL}_${DATE_GMT}" -->
     

    Conditional expressions

    <!--#if expr="test_condition" --><!--#elif expr="test_condition" --><!--#else --><!--#endif -->
     

    1、Config命令

      Config命令主要用于修改SSI的默认设置。其中:

      Errmsg:设置默认错误信息。为了能够正常的返回用户设定的错误信息,在HTML文件中Errmsg参数必须被放置在其它SSI命令的前面,否则客户端只能显示默认的错误信息,而不是由用户设定的自定义信息。

        <!--#config errmsg="Error! Please email webmaster@mydomain.com --> 

      Timefmt:定义日期和时间的使用格式。Timefmt参数必须在echo命令之前使用。

        <!--#config timefmt="%A, %B %d, %Y"-->
        <!--#echo var="LAST_MODIFIED" -->

      显示结果为:
        
        Wednesday, April 12, 2000 

    9 7 3 1 2 4 8 :

    用户评论

    广而告之