From: Eric Covener mod_include
- documentation.
For example, if you wish to customize the text on your web page - based on the time of day, you could use the following recipe, placed - in the HTML page:
- -
- Good
- <!--#if expr="%{TIME_HOUR} >=12" -->
- morning!
- <!--#else -->
- afternoon!
- <!--#endif -->
-
In your configuration file, you could put the following + line:
+
+ BrowserMatchNoCase macintosh Mac
+ BrowserMatchNoCase MSIE InternetExplorer
+
This will set environment variables ``Mac'' and + ``InternetExplorer'' to true, if the client is running Internet + Explorer on a Macintosh.
+ +Then, in your SSI-enabled document, you might do the + following:
+
+ <!--#if expr="${Mac} && ${InternetExplorer}" -->
+ Apologetic text goes here
+ <!--#else -->
+ Cool JavaScript code goes here
+ <!--#endif -->
+
Not that I have anything against IE on Macs - I just + struggled for a few hours last week trying to get some + JavaScript working on IE on a Mac, when it was working + everywhere else. The above was the interim workaround.
Any other variable (either ones that you define, or normal environment variables) can be used in conditional statements. - See Expressions in Apache HTTP Server for - more information on the expression evaluation engine.
- -With Apache's ability to set environment variables with the
+ With Apache's ability to set environment variables with the
SetEnvIf
directives, and other related directives,
- this functionality can let you do a wide variety of dynamic content
- on the server side without resorting a full web application.