Read More

Rewrite

Table of Contents

Rewrite Control

Enable Rewrite | Log Level

Rewrite Map

Name | Location

Rewrite Rules

Rewrite Rules

Enable Rewrite

Description

Specifies whether to enable LiteSpeed's URL rewrite engine. This option can be customized at the virtual host or context level, and is inherited along the directory tree until it is explicitly overridden.

Syntax

Select from radio box

Log Level

Description

Specifies the level of detail of the rewrite engine's debug output. This value ranges from 0 - 9. 0 disables logging. 9 produces the most detailed log. The server and virtual host's error log Log Level must be set to at least INFO for this option to take effect. This is useful when testing rewrite rules.

Syntax

Integer number

See Also

Server Log Level, Virtual Host Log Level

Name

Description

Specifies a unique name for the rewrite map at the virtual host level. This name will be used by a mapping-reference in rewrite rules. When referencing this name, one of the following syntaxes should be used:

$\{MapName:LookupKey\}
$\{MapName:LookupKey|DefaultValue\}

The implementation of LiteSpeed's rewrite engine follows the specifications of Apache's rewrite engine. For more details about rewrite maps, please refer to Apache's mod_rewrite document.

Syntax

string

Location

Description

Specifies the location of the rewrite map using the syntax MapType:MapSource.
LiteSpeed's 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 this 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, except that the second element can contain multiple choices separated by a "|" sign and 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 have not been implemented in LiteSpeed:
    Hash File and External Rewriting Program.
The implementation of LiteSpeed's rewrite engine follows the specifications of Apache's rewrite engine. For more details about rewrite map, please refer to Apache's mod_rewrite document.

Syntax

String

Rewrite Rules

Description

Specifies a list of rewrite rules at the 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 from your Apache configuration files.
  • There are minor differences between LiteSpeed and Apache mod_rewrite implementation:
    • %\{LA-U:variable\} and %\{LA-F:variable\} are ignored by the LiteSpeed rewrite engine
    • two new server variables are added in the LiteSpeed rewrite engine: %\{CURRENT_URI\} represents the current URI being processed by the rewrite engine and %\{SCRIPT_NAME\} has the same meaning as the corresponding CGI environment variable.
The implementation of LiteSpeed's rewrite engine follows the Apache's rewrite engine specifications. For more details about rewrite rules, please refer to Apache's mod_rewrite document and Apache's URL rewriting guide.

Syntax

string

Accelerate your internet now.