### OpenLiteSpeed Web Server Users' Manual

##### Version 1.4 — Rev. 30

- 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

# Static Context

## Table of Contents

### Static Context⇑

#### Description

Context settings are used to specify special settings for files in a certain location. These settings can be used to bring in files outside of the document root (like Apache's Alias or AliasMatch directives), to protect a particular directory using authorization realms, or to block or restrict access to a particular directory within the document root.

### URI⇑

#### Description

Specifies the URI for this context.

#### Syntax

The URI can be a plain URI (starting with "/") or a Perl compatible regular expression URI (starting with "exp:"). If a plain URI ends with a "/", then this context will include all sub-URIs under this URI. If the context maps to a directory on the file system, a trailing "/" must be added.

#### See Also

Location

### Location⇑

#### Description

Specifies the corresponding location of this context in the file system.
Default value: $DOC_ROOT + URI

#### Syntax

It can be an absolute path or path relative to $SERVER_ROOT, $VH_ROOT, or $DOC_ROOT. $DOC_ROOT is the default relative path, and can be omitted.
If the URI is a regular expression, then the matched sub-string can be used to form the "Root" string. The matched sub-string can be referenced with the values "$1" - "$9". "$0" and "&" can be used to reference the whole matched string. Additionally, a query string can be set by appending a "?" followed by the query string. Be careful. "&" should be escaped as "\&" in the query string.

#### Example

A plain URI like /examples/ with Location set to /home/john/web_examples will map the request "/examples/foo/bar.html" to file "/home/john/web_examples/foo/bar.html".
To simulate Apache's mod_userdir, set URI to exp: ^/~([A-Za-z0-9]+)(.*), set Location to /home/$1/public_html$2. With these settings, a request of URI /~john/foo/bar.html will map to file /home/john/public_html/foo/bar.html.

#### See Also

URI

### Accessible⇑

#### Description

Specifies whether this context can be accessed. Set to No to deny access. You can use this feature to protect the specified directory from being visited. You may use it when you are updating contents for this context or you have special data in this directory.

#### Syntax

Select from radio box

### 启用过期⇑

#### Description

指定是否为静态文件生成Expires头。如果启用，将根据 默认过期和按类型过期生成Expires头。
这可以在服务器，虚拟主机和Context级别设置。低级别的设置将 覆盖高级别的设置。例如，Context级别的设置将覆盖虚拟主机级别的设置， 虚拟主机级别的设置将覆盖服务器级别的设置。

#### Syntax

布尔值

### 默认过期⇑

#### Description

指定生成Expires头的默认设置。该设置在启用过期 设为“启用”时有效。它可以被按类型过期覆盖。 除非必要，否则不要在服务器或虚拟主机级别设置该默认值。 因为它会为所有网页生成Expires头。大多数时候，应该是 为不常变动的某些目录在Context级别设置。如果没有默认设置，按类型过期中未指定的类型不会生成Expires头。

#### Syntax

A|M秒数
文件将在基准时间（A|M）加指定秒数的时间后失效。 “A”代表基准时间为客户端的访问时间，“M”代表文件的最后修改时间。

### 按类型过期⇑

#### Description

为各个MIME类型分别指定Expires头设置。

#### Syntax

逗号分隔的“MIME-类型=A|M秒数”的列表。 文件将在基准时间（A|M）加指定秒数的时间后失效。
“A”代表基准时间为客户端的访问时间，“M”代表文件的最后修改时间。 MIME-类型可使用通配符“*”，如image/*。

### Header Operations⇑

#### Description

Specifies additional response/request headers to be added. Multiple header directives can be added with one directive per line. "NONE" can be used to disable parent header inheritance. If no directive is provided 'Header' is assumed.

#### Syntax

[Header]|RequestHeader [condition] set|append|merge|add|unset header [value] [early|env=[!]variable]

#### Example

set Cache-control no-cache
append Cache-control no-store
Header set My-header cust_header_val
RequestHeader set My-req-header cust_req_header_val

#### Tips

Syntax and usage are similar to Apache's mod_headers directives for supported operations.
The 'Header' directive is is optional and can be excluded or left in when copying rules from elsewhere without issue.

### MIME Type⇑

#### Description

Specifies additional MIME types and mappings for this context. New mappings will override existing mappings under this context and its children contexts.
If you want to show PHP scripts as text files instead of being executed as scripts, just override the .php mapping to MIME type "text/plain".

#### Syntax

MIME-type1 extension extension ..., MIME-type2 extension ... Use comma to separate between MIME types, use space to separate multiple extensions.

#### Example

image/jpg jpeg jpg, image/gif gif

### Force MIME Type⇑

#### Description

When specified, all files under this context will be served as static files with the MIME type specified regardless of file suffix. When set to NONE, inherited force type setting will be disabled.

#### Syntax

MIME type or NONE.

### Default MIME Type⇑

#### Description

When specified, this type will be used when MIME type mapping cannot be determined by the suffix of a document or if there is no suffix. If not specified, the default value application/octet-stream will be used.

#### Syntax

MIME-type

### 索引文件⇑

#### Description

指定URL映射到目录时顺序查找的索引文件名称。 您可以在服务器、虚拟主机和Context级别对其进行自定义。

#### Syntax

逗号分隔的索引文件名列表。

#### Tips

[性能建议] 只设置你需要的索引文件。

### 自动索引⇑

#### Description

在目录中，当索引文件中所列的索引文件不可用时，指定运行时是否即时生成目录索引。
此选项可以在虚拟主机级别和context级别中设置，并可以顺着目录树继承，直到被覆盖。 您可以自定义生成的索引页面。请访问在线百科了解如何操作。

#### Syntax

布尔值

#### Tips

[安全建议] 建议关闭自动索引，从而尽可能防止泄露机密数据。

#### See Also

索引文件, 自动索引URI

### Realm⇑

#### Description

指定这个context下的realm授权。 当指定时，必须提供有效的用户和用户名来访问这个context。 Realms授权需要在Virtual Host Security部分进行设置。此设置使用每个realm的Realm名称。

#### Syntax

选项

### 认证名称⇑

#### Description

为当前context下的realm认证指定一个替代的名称。 如果没有指定，原realm名称将被使用。 认证名称将显示在浏览器登陆弹出窗口。

#### Syntax

文本

### Require（授权的用户/组）⇑

#### Description

指定哪些用户/用户组可以访问此context。 这里允许你使用一个用户/组数据库(在 Realm中指定)访问多个context， 但只允许该数据库下特定的用户/组访问这个context。

#### Syntax

语法兼容Apache的Require指令。例如:

- user username [username ...]
  只有列出的用户可以访问这个context;
- group groupid [groupid ...]
  用户必须属于列出的组才可以访问这个context。

如果没有指定，所有有效的用户都可以访问这个资源。

### 允许访问列表⇑

#### Description

指定允许访问这个context下资源的IP地址或子网。综合 拒绝访问列表项的配置以及服务器/虚拟主机级别访问控制， 可访问性将以客户端IP所符合的最小范围来确定。

#### Syntax

逗号分隔的IP地址/子网列表。

#### Example

子网络可以写成192.168.1.0/255.255.255.0, 192.168.1 或192.168.1.*。

### 拒绝访问列表⇑

#### Description

指定哪个IP地址或子网不被允许访问这个context下的资源。 综合允许访问列表项的配置以及服务器/虚拟主机级别访问控制， 可访问性将以客户端IP所符合的最小范围来确定。

#### Syntax

逗号分隔的IP地址/子网列表。

#### Example

子网络可以写成192.168.1.0/255.255.255.0, 192.168.1 或192.168.1.*。

### Authorizer⇑

#### Description

Specifies an external application that can be used to generate authorized/unauthorized decisions. Currently, only the FastCGI Authorizer is available. For more details about the FastCGI Authorizer role, please visit http://www.fastcgi.com.

#### Syntax

Select from drop down list

### 添加默认的字符集⇑

#### Description

指定当内容类型是"text/html"或"text/plain"且没有参数时，是否添加字符集标记到"Content-Type"响应报头中。当设置为Off时，该功能禁用。当设置为On时，将添加自定义默认字符集中指定的字符集，如果没有指定，将添加默认的"iso-8859-1"字符集。

#### Syntax

布尔值

### 自定义默认字符集⇑

#### Description

指定一个字符集当添加默认的字符集是On时使用。这是可选的。默认值是iso-8859-1。当添加默认的字符集是Off时本设置将不生效。

#### Syntax

字符集的名称，例如utf-8

#### Example

utf-8

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

### 重写继承⇑

#### Description

指定是否从父级context继承重写规则。 如果启用重写但不继承，将启用本context的重写基准及重写规则。

#### Syntax

布尔值

### 重写基准⇑

#### Description

指定重写规则的基准URL。

#### Syntax

URL

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

### 启用IP地理定位⇑

#### Description

指定是否启用IP地理定位查找。 可以在服务器级别，虚拟主机级别，或context级别设置。

#### Syntax

布尔值

#### See Also

使用报头中的客户端IP, 数据库文件路径,

### php.ini Override⇑

#### Description

Used to overwrite php.ini settings in the current context (Virtual Host level or Context level).
Supported directives are:
php_value
php_flag
php_admin_value
php_admin_flag
All other lines/directives will be ignored.

#### Syntax

Override syntax is similar to Apache, a newline separated list of directives and their values with each directive being prepended by php_value, php_flag, php_admin_value, or php_admin_flag appropriately.

#### Example

php_value include_path ".:/usr/local/lib/php"
php_admin_flag engine on
php_admin_value open_basedir "/home"