-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssi.html
147 lines (107 loc) · 5 KB
/
ssi.html
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<html>
<head>
<!-- makes browser more consistent -->
<link rel="stylesheet" href="css/normalize.css">
<!-- necessary for rainbow js -->
<link rel="stylesheet" href="css/solarized-light.css">
<!-- cheatsheet specific stylesheets -->
<link rel="stylesheet" href="css/cheatsheet.css">
</head>
<body data-language="html">
<h1>Server Side Includes</h1>
<div class="container">
<article>
<h2>Installation (Apache)</h2>
<ol>
<li>Uncomment module in <i>httpd.conf</i>: <code>LoadModule include_module modules/mod_include.so mod_include</code></li>
<li>Configure module in <i>httpd.conf</i> or <i>.htaccess</i>:
<code class="multiline"># Enable SSI
Options +Includes
# Parse all .shtml files ...
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
# ... or parse all.html files (bad performance!) ...
#AddOutputFilter INCLUDES .html
# ... or parse all files with the execute bit set (unix only)
XBitHack on</code></li>
<li>For XBitHack, change the execute bit: <code>chmod +x file.html</code></p>
</ol>
</article>
<article>
<h2>Basic Commands</h2>
<p><strong> Whitespace is important!</strong></p>
<dl>
<dt><code><!--#include file="ssi-file.html" --></code></dt>
<dd>Replaces the comments with the content of <i>ssi-file.html</i>. Path must be relative to the current file. Cannot contain <code>../</code></dd>
<dt><code><!--#include virtual="ssi-file.html" --></code></dt>
<dd>URL-path. Either absolute to the root (begins with <code>/</code>) or relative to the current file. Can be used to point to cgi</dd>
<dt><code><!--#include virtual="/a.html" onerror="/error.html" --></code></dt>
<dd>Show the content of <i>error.html</i> if the include doesn't work<dd>
<dt><code><pre><!--#printenv --></pre></code></dt>
<dd>Show all available variables</dd>
</dl>
</article>
<article>
<h2>Legacy expression syntax</h2>
<p>Used before version 2.3.13. To active it in newer versions add <code>SSILegacyExprParser on</code> to <i>.htaccess</i> or <i>httpd.conf</i></p>
<hr/>
<dl>
<dt><code>$variable</code></dt>
<dd>value of variable</dd>
<dt><code>string</code></dt>
<dd>true if string is not empty. Everything that's not a variable or operator is treated as a string. Strings that contain whitespace must be quoted: <code>'string'</code></dd>
<dt><code>-A string</code></dt>
<dd>true if the URL represented by the string is accessible. Useful to show content/links only to authorized users.</dd>
<dt><code>string1 = string2</code> or <code>string1 == string2</code></dt>
<dd>true if the two strings are equal</dd>
<dt><code>string = /regex/</code> or <code>string == /regex/</code></dt>
<dd>true if the string matches the <a href="http://perldoc.perl.org/perlre.html">regular expression</a>. Groups are stored in the variables $0 .. $9 and can be accessed later in the code</dd>
<dt><code>string1 != string2</code> or <code>string != /regex/</code></dt>
<dd>true if the two strings are not equal / string doesn't match the regular expression</dd>
<dt><code>str1 < str2</code> or <code>str1 <= str2</code> or <code>str1 > str2</code> or <code>str1 >= str2</code></dt>
<dd>Compare string1 with string2. Strings are compared literally (using strcmp(3)). Therefore the string "100" is less than "20"</dd>
<dt><code>( condition )</code></dt>
<dd>Can be used to clarify the order of operations</dd>
<dt><code>! condition</code></dt>
<dd>Negates the condition</dd>
<dt><code>test_condition1 && test_condition2</code></dt>
<dd>true if both test_condition1 and test_condition2 are true</dd>
<dt><code>test_condition1 || test_condition2</code></dt>
<dd>true if either test_condition1 or test_condition2 is true</dd>
</article>
<article>
<h2>Flow Control</h2>
<p><code class="multiline"><!--#if expr="v('DOCUMENT_NAME') == 'index.html'" -->
<h1>Start here</h1>
<!--#elif expr="v('DOCUMENT_NAME') == 'contact.html'" -->
<h1>Please contact us!</h1>
<!--#else -->
<h1>Unknown site</h1>
<!--#endif --></code></p>
<p>The condition follows the <a href="http://httpd.apache.org/docs/trunk/expr.html">ap_expr</a> or the legacy expression syntax (see below). Use <code><!--#printenv --></code> to see all available variables.</p>
</article>
<article class="small">
<h2>More Information</h2>
<ul>
<li><a href="http://httpd.apache.org/docs/current/mod/mod_include.html">Module Documentation</a></li>
<li><a href="http://httpd.apache.org/docs/trunk/expr.html">Apache Epressions (ap_expr)</a></li>
</ul>
</article>
<article class="small">
<h2>Other Commands</h2>
<ul>
<li>config</li>
<li>echo</li>
<li>exec</li>
<li>fsize</li>
<li>flastmod</li>
<li>set</li>
</ul>
</dl>
</article>
</div>
<!-- syntax highlighting -->
<script src="js\cheatsheet.js"></script>
<script src="js\rainbow-custom.min.js"></script>
</body>
</html>