Skip to content

Architecture

LiteHTTPD is an LSIAPI module (litehttpd_htaccess.so) that hooks into OpenLiteSpeed at two request lifecycle phases. The same .so binary is used in both editions: LiteHTTPD-Thin runs on stock OLS and provides all directives except RewriteRule execution and php_value passthrough. LiteHTTPD-Full runs on patched OLS (via openlitespeed-litehttpd RPM) and adds RewriteRule execution, php_value/php_flag, Options -Indexes 403, and readApacheConf. The module detects patch availability at runtime via NULL pointer checks on the extended LSIAPI function pointers.

Client Request
|
v
+-------------------+
| OLS Engine |
| PROCESS_NEW_URI |
| VHOST_REWRITE |
| CONTEXT_MAP |
+-------------------+
|
v
+-------------------+ +------------------+
| URI_MAP Hook | --> | mod_htaccess.c |
| (Request Phase) | | on_uri_map() |
+-------------------+ +------------------+
| |
| +----------------------+
| | htaccess_dirwalk()
| | -> parse .htaccess files
| | -> merge directives
| | -> AllowOverride filter
| +----------------------+
| |
| Execute request-phase directives:
| - ACL (Order/Allow/Deny)
| - Auth (AuthType/Require)
| - Redirect/RedirectMatch
| - RewriteRule (via OLS engine)
| - PHP config (php_value/flag)
| - SetEnv/SetEnvIf
| - Options
| - If/ElseIf/Else chains
|
v
+-------------------+
| OLS Engine |
| FILE_MAP |
| PHP Processing |
+-------------------+
|
v
+-------------------+ +------------------+
| SEND_RESP_HEADER | --> | mod_htaccess.c |
| (Response Phase) | | on_send_resp() |
+-------------------+ +------------------+
| |
| Execute response-phase directives:
| - Header set/unset/append/merge
| - If/ElseIf/Else (response children)
| - Expires/Cache-Control
| - AddType/ForceType/AddCharset
| - ErrorDocument
|
v
Response to Client
FilePurposeLOC
mod_htaccess.cLSIAPI entry point, hooks, directive dispatch~1900
htaccess_parser.cApache .htaccess syntax parser~2500
htaccess_dirwalker.cDirectory walk, merge, AllowOverride~1000
htaccess_cache.cLRU cache for parsed directives~300
htaccess_directive.cDirective data structures and free~200
htaccess_expr.cap_expr expression evaluator~800
htaccess_printer.cAST to text serialization~400
lsiapi_shim.cLSIAPI function wrappers~400

Executor Modules (one per directive category)

Section titled “Executor Modules (one per directive category)”
FileHandles
htaccess_exec_acl.cOrder, Allow, Deny
htaccess_exec_auth.cAuthType, AuthName, AuthUserFile, Require valid-user
htaccess_exec_header.cHeader, RequestHeader (all variants)
htaccess_exec_redirect.cRedirect, RedirectMatch, ErrorDocument
htaccess_exec_rewrite.cRewriteEngine, RewriteRule, RewriteCond
htaccess_exec_expires.cExpiresActive, ExpiresByType, ExpiresDefault
htaccess_exec_require.cRequire all/ip/env, RequireAny/All
htaccess_exec_env.cSetEnv, SetEnvIf, BrowserMatch
htaccess_exec_php.cphp_value, php_flag
htaccess_exec_options.cOptions
htaccess_exec_limit.cLimit, LimitExcept
htaccess_exec_files_match.cFilesMatch
htaccess_exec_handler.cAddHandler, SetHandler (no-op)
htaccess_exec_forcetype.cForceType
htaccess_exec_encoding.cAddType, AddEncoding, AddCharset
htaccess_exec_brute_force.cLSBruteForce*

LiteHTTPD uses a multi-level caching strategy:

  1. File-level cache (htaccess_cache.c) — parsed directive trees cached by file path + mtime + st_blocks
  2. Request-level cache (req_cache) — thread-local cache storing directives between URI_MAP and SEND_RESP_HEADER hooks for the same request
  3. Rewrite handle cache (rw_cache) — thread-local cache for compiled RewriteRule handles, keyed by directive fingerprint
  4. Negative stat cache — thread-local cache of non-existent .htaccess paths to avoid repeated stat() calls
  • All caches use __thread (thread-local storage) — no locks needed
  • OLS uses multi-process, single-thread-per-process architecture
  • The module is reentrant within a single worker process