### OpenLiteSpeed Web Server Users' Manual

##### Version 1.6 — Rev. 2

- License
- Introduction
- Installation
- Administration
  - Service Manager
- Security
- Configuration
  - Server General
  - Server Log
  - Server Tuning
  - Server Security
  - External Apps
  - Fast CGI App
  - Fast CGI Authorizer
  - LSAPI App
  - Servlet Engine
  - Web Server
  - Piped logger
  - Load Balancer
  - Script Handler
  - App Server Settings
  - Module Configuration
  - Listener General
  - Listener SSL
  - Virtual Host Templates
  - Virtual Host Basic
  - Virtual Host General
  - Virtual Host Security
  - Virtual Host SSL
  - Rewrite
  - Context
  - Static Context
  - Java Web App Context
  - Servlet Context
  - Fast CGI Context
  - LSAPI Context
  - Proxy Context
  - CGI Context
  - Load Balancer Context
  - Redirect Context
  - App Server Context
  - Module Handler Context
  - Web Socket Proxy
- Web Console
  - Admin Console General
  - Admin Console Security
  - Admin Listener General
  - Admin Listener SSL

# Rewrite

## Table of Contents

### 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

### Auto Load from .htaccess⇑

#### Description

Autoload rewrite rules contained in a directory's .htaccess file when first accessing that directory if an HttpContext for that directory using the rewritefile directive does not already exist. Once initially loaded, a graceful restart must be performed for any further changes to that .htaccess file to take effect.
Virtual Host-level setting overrides Server-level setting. Default values:
Server-level: No
VH-Level: Inherit Server-level setting

#### 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 level.
Do NOT add any document root level rewrite rules here. If you have any document root level rewrite rules from .htaccess, you should instead create a static context with uri "/" and add the rewrite rules there.
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