## OpenLiteSpeed Web Server Users' Manual

### Version 1.7 — Rev. 18

- 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

# 重写帮助

## Table of Contents

### 启用重写⇑

#### Description

指定是否启用LiteSpeed的URL重写. 可以在虚拟主机或context级别上自定义此选项， 并且沿目录树继承该选项，直到被其他选项覆。

#### Syntax

从单选框选择

### 自动加载.htaccess⇑

#### Description

如果使用rewritefile指令的目录的HttpContext不存在，则在初次访问该目录时自动加载.htaccess文件中包含的重写规则。 最初加载后，必须执行正常重启才能使对该.htaccess文件的修改生效。
虚拟主机级别设置将覆盖服务器级别设置。 默认值：
Server-level: No
VH-Level: Inherit Server-level setting

#### Syntax

从单选框选择

### 日志级别⇑

#### Description

指定重写调试输出的详细程度。 此值的范围是0-9。 设置为0将禁用日志记录。 设置为9将产生 最详细的日志。 服务器和虚拟主机的错误日志日志级别 至少设置为INFO才能使此选项生效。 这对测试重写规则很有帮助。

#### Syntax

整数

#### See Also

Server 日志级别, Virtual Host 日志级别

### 名称⇑

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

### 重写规则⇑

#### Description

指定虚拟主机级别的重写规则。
请勿在此处添加任何目录级重写规则。 如果您在.htaccess有任何目录级的重写规则，则应该使用uri"/"创建一个静态context， 并在那里添加重写规则。
重写规则由一个RewriteRule组成，并可可以在多个RewriteCond之后。

- 每行仅能有一条规则
- RewriteCond 和 RewriteRule 遵循Apache的rewrite语法。 只需从Apache配置文件中复制并粘贴重写规则即可。
- LiteSpeed和Apache mod_rewrite之间有细微差别：
  - %\{LA-U:variable\} and %\{LA-F:variable\} 在Litespeed 重写中将被忽略
  - Litespeed中加入了两个新变量: %\{CURRENT_URI\}表示正在处理的URL %\{SCRIPT_NAME\}表示为相应的CGI环境变量。
  - Litespeed在遇到[L]后为了避免循环将停止处理此及此后的重写规则 而Apache mod_rewrite将仅停止处理该条重写规则。此行为类似于apachemod_rewrite中的[END]标志。

LiteSpeed的重写规则遵循Apache的重写规范。 有关重写规则的更多详细信息，请参阅 Apache's mod_rewrite document(英文文档) 和 Apache's URL rewriting guide(英文文档) .

#### Syntax

string