Rewrite
 
Table of Contents
Rewrite Control Enable Rewrite   Rewrite Log Level   
Rewrite Map Name   Location   
Rewrite Rules Rewrite Rules   
 
Enable RewriteGo to top
Description: Specifies whether to enable LiteSpeed URL rewrite engine. This option can be customized at virtual host and context level, and is inherited along the directory tree until it is explicitly overridden.
Syntax: Select from radio box
Rewrite Log LevelGo to top
Description: Specifies how detail of the rewrite engine debug output. Value ranges from 0 - 9, 0 will disable logging and 9 will produce the most detailed log. The log level of the server and the virtual host's error log must be set to at least INFO for this option to take effect. This is useful when testing your rewrite rules.
Syntax: Integer number
See Also: Server Log Level, Virtual Host Log Level
NameGo to top
Description: Specifies a unique name for the rewrite map at virtual host level. This name will be used by a mapping-reference in rewrite rules via one of the following syntax:
$\{MapName:LookupKey\}
$\{MapName:LookupKey|DefaultValue\}
The implementation of LiteSpeed rewrite engine follows the specification of the Apache rewrite engine. For more details about rewrite map, please refer to Apache's mod_rewrite document.
Syntax: string
LocationGo to top
Description: Specifies the location of the rewrite map in syntax of MapType:MapSource.
LiteSpeed rewrite engine supports three types of rewrite maps:
  • Standard Plain Text
    MapType: txt; MapSource: file path to a valid plain ASCII file.
    Each line of the file should contain two elements separated by blank spaces. The first element is the key and the second element is the value. Comments can be added with a leading "#" sign.

  • Randomized Plain Text
    MapType: rnd; MapSource: file path of a valid plain ASCII file.
    File format is similar to the Standard Plain Text file, the second element can contain multiple choices separated by a "|" sign and is chosen randomly by the rewrite engine.

  • Internal Function
    MapType: int; MapSource: Internal string function
    4 functions are available:
    • toupper: converts lookup key to upper cases.
    • tolower: converts lookup key to lower cases.
    • escape: perform URL encoding on lookup key.
    • unescape: perform URL decoding on lookup key.

  • The following map types available in Apache but not implemented within LiteSpeed: Hash File and External Rewriting Program.
The implementation of LiteSpeed rewrite engine follows the specification of Apache rewrite engine, For more details about rewrite map, please refer to Apache's mod_rewrite document.
Syntax: string
Rewrite RulesGo to top
Description: Specifies a list of rewrite rules at virtual host or context level. A rewrite rule is comprised of one RewriteRule directive and optionally preceded by multiple RewriteCond directives.
  • Each directive should take only one line.
  • RewriteCond and RewriteRule follow Apache's rewrite directive syntax, just copy and paste rewrite directives in your Apache configuration files over.
  • There are minor differences between LiteSpeed and Apache mod_rewrite implementation:
    • %\{LA-U:variable\} and %\{LA-F:variable\} are ignored by LiteSpeed rewrite engine,
    • two new server variables are added in LiteSpeed rewrite engine: %\{CURRENT_URI\} represents the current URI processed by rewrite engine; %\{SCRIPT_NAME\} has the same meaning as the corresponding CGI environment variable.
The implementation of LiteSpeed rewrite engine follows the specification of Apache rewrite engine, For more details about rewrite rules, please refer to Apache mod_rewrite document and Apache URL Rewriting guide.
Syntax: string