Skip to content

LiteSpeed .htaccess compatibility: what works, what does not

A practical reference of Apache .htaccess directives and their LiteSpeed equivalents — which are natively supported, which require workarounds, and which are silently ignored.

LiteSpeed Enterprise reads .htaccess per request and honours the large majority of what a WordPress site puts in one: all of mod_rewrite, mod_headers, mod_expires, gzip output, both the modern and the legacy access-control syntax, and the Files, FilesMatch and Directory contexts around them. What it does not honour, it does not complain about. An unsupported directive on LiteSpeed is a no-op, not a syntax error, so the site keeps serving normally while a rule you believe is protecting something quietly does nothing at all. The coarser failure is worse: if a virtual host has Auto Load from .htaccess switched off, the file is never read, and every rule in it disappears at once. This page is the directive-by-directive reference, plus the request-level procedure that proves any single rule actually took effect.

What you’ll accomplish

  • Read a directive-by-directive compatibility table covering the modules a WordPress or cPanel .htaccess actually uses, split into native, different-scope, and silently-ignored.
  • Confirm that the virtual host reads .htaccess at all, which is the single most common reason a file appears to be completely ignored on a standalone LiteSpeed install.
  • Check that AllowOverride permits the class of directive you are trying to set, exactly as you would on Apache.
  • Prove each rule took effect with a request-level test instead of trusting that a saved file means an applied rule.
  • Know which changes are live on the next request and which need lswsctrl restart.

Prerequisites

  • LiteSpeed Enterprise (LSWS) 6.x, installed at the default prefix /usr/local/lsws/. OpenLiteSpeed does not read .htaccess the same way and most of this page does not apply to it.
  • Root or shell access to inspect /usr/local/lsws/conf/ and the Apache configuration LiteSpeed is consuming, plus WebAdmin on port 7080 if you prefer the console.
  • cPanel/WHM is assumed but not required. On cPanel, LiteSpeed parses Apache’s own httpd.conf and the per-account vhost includes, and .htaccess loading is on by default. On a standalone LSWS install it may not be.
  • A machine that can reach the site over HTTPS with curl. Every proof in this article is a request, not a config read.
  • Behaviour of php_value and php_flag depends on how PHP is executed. Know whether the account runs LSAPI (lsphp) or a suPHP-style handler before you rely on either.

The compatibility table

Directive or moduleStatus on LiteSpeedWhat to know
RewriteEngine, RewriteRule, RewriteCond, RewriteBaseNativeParsed per request. WordPress permalink blocks work unchanged.
Flags [L], [R=301], [QSA], [NC], [E=VAR:value]NativeIncluding chained conditions and backreferences. [E=] sets an environment variable LiteSpeed can act on.
Header set / add / append / unset (mod_headers)NativeThe always and onsuccess conditions are honoured. Without always, the header is only added to successful responses.
ExpiresActive, ExpiresByType, ExpiresDefaultNativeSame syntax and same computed Cache-Control.
mod_deflate / gzip output filtersNativeLiteSpeed compresses by its own configuration; the filter directives do not conflict with it.
Require all granted / Require all denied (mod_authz_core)NativeThe 2.4 access-control syntax.
Order, Allow from, Deny fromNativeThe legacy 2.2 syntax is still understood, which matters for older WordPress hardening snippets.
AddType, AddHandler, AddDefaultCharset (mod_mime)NativeHandler assignment is how cPanel switches PHP versions per directory.
SetEnvIf, SetEnvIfNoCase, BrowserMatchNativeUseful for pairing with Header set ... env= conditions.
ErrorDocumentNativeBoth the path form and the inline-text form.
DirectoryIndexNative
Options -Indexes, Options +FollowSymLinksNativeSubject to AllowOverride Options, exactly as on Apache.
Redirect, RedirectMatchNative
<Files>, <FilesMatch>, <Directory>, <IfModule>NativeContainer contexts nest as expected.
php_value, php_flagHandler-dependentApplied when PHP runs through LSAPI. Under a suPHP-style handler they are not, and you set the value in the account’s php.ini instead.
LimitRequestBodyDifferent scopeThe server-wide and per-vhost request body limit wins. A per-directory value cannot raise the ceiling above it.
ModSecurity Sec* directivesDifferent scopeLiteSpeed runs its own ModSecurity engine, enabled per server or per virtual host, not from .htaccess.
CacheEnable, CacheRoot (Apache mod_cache)IgnoredThese are not valid in .htaccess on Apache either. LiteSpeed caching is LSCache, which is a different mechanism.
ProxyPass, ProxyPassReverse (mod_proxy)IgnoredProxying belongs in the virtual host’s external application and context configuration.
DOSPageCount, DOSSiteCount (mod_evasive)IgnoredLiteSpeed has its own per-client throttling settings in the server and vhost security configuration.
UserDir (mod_userdir)Ignored
SetOutputFilter RATE_LIMIT (mod_ratelimit)IgnoredBandwidth shaping is a LiteSpeed throttling setting, not an .htaccess directive.
SetHandler server-status (mod_status)IgnoredLiteSpeed reports status through WebAdmin and its own real-time report.
SSLRequireSSLIgnoredForce HTTPS with a RewriteCond %{HTTPS} !=on rule instead, which is native.
<IfModule LiteSpeed>LiteSpeed onlyApache skips the block; LiteSpeed enters it. This is how you keep a file portable across both.
CacheLookup on, CacheDisableLiteSpeed onlyLSCache controls. They belong inside an <IfModule LiteSpeed> guard.
RewriteRule ... [E=cache-control:max-age=N]LiteSpeed onlySets the LSCache TTL for the matched request. Harmless on Apache, which just sets an unused environment variable.

Everything in the “Ignored” rows shares one property, and it is the property that costs people time: nothing is written to the error log, no 500 is raised, and the page renders exactly as before.

How it works

.htaccess on LiteSpeed is not an emulation layer bolted on top of a different config system. The server parses the file itself, on the way through the request, in the same per-directory order Apache uses: the document root’s file first, then each subdirectory down to the one containing the requested resource. That is why a rewrite you save is live on the next request without a restart. Two gates sit in front of that parse, and both of them are silent when they are closed.

Request path through LiteSpeed showing where .htaccess is consulted: request arrives, virtual host matched, the Auto Load from .htaccess gate marked as the warning point, AllowOverride scope, directives applied in order as rewrite then headers then expires then access rules, LSCache lookup, PHP through LSAPI, and the response, with side notes on what happens when the gate is off and on how Apache walks the same file

The first gate is the virtual host’s rewrite configuration. In WebAdmin this is Virtual Hosts > (your host) > Rewrite, with two controls that matter: Enable Rewrite and Auto Load from .htaccess. In the vhost config file they appear as enable and autoLoadHtaccess inside a rewrite block. On a cPanel server both are on, because the LiteSpeed WHM plugin sets them that way for every account. On a hand-built LSWS install they are frequently not, and that produces the specific symptom of a file that seems to be ignored in its entirety rather than partially.

The second gate is AllowOverride, and it behaves exactly as documented for Apache. It lives in the Apache configuration LiteSpeed is reading, not in .htaccess itself, and it decides which classes of directive a .htaccess may set at all. AllowOverride None disables the file completely; AllowOverride FileInfo permits rewrites and headers but not Options -Indexes, which needs AllowOverride Options. The detail of which override class covers which directive is worked through in AllowOverride on cPanel.

Past both gates, directives apply in a fixed order: rewriting resolves the URL, then access control decides whether to serve it, then headers and expiry are attached to the response. LSCache is consulted after rewriting, which is the reason a cached page can answer before a newly added access rule is ever evaluated.

Step-by-step

  1. Confirm LiteSpeed is the server answering, and that it is running. The response header proves the server family; lswsctrl proves the daemon state.

    curl -sI https://example.com/ | grep -i '^server:'
    /usr/local/lsws/bin/lswsctrl status
    server: LiteSpeed
    litespeed is running with PID 1148.
  2. Confirm the virtual host actually loads .htaccess. This is the check to run first when the whole file appears to be ignored.

    grep -r -A3 'rewrite' /usr/local/lsws/conf/vhosts/ | grep -E 'enable|autoLoadHtaccess'

    A host that reads the file shows both set to 1:

    enable                  1
    autoLoadHtaccess        1

    If either is 0, set it in WebAdmin under Virtual Hosts > (host) > Rewrite and restart. On cPanel these values are managed by the plugin and you should not hand-edit the generated files.

  3. Check the AllowOverride scope for the document root. LiteSpeed reads this from the Apache configuration it inherited.

    grep -r -n 'AllowOverride' /etc/apache2/conf/httpd.conf

    Expect AllowOverride All for a normal cPanel account. None means no .htaccess is consulted anywhere under that directory.

  4. Audit the file against the three categories before you debug anything. Read your .htaccess once with the matrix in mind and mark every line that falls in the third column, because those lines will never report a problem on their own.

    Three-column support matrix for .htaccess on LiteSpeed: native directives that behave as on Apache, directives with a different scope such as ModSecurity and php_value and the LiteSpeed-only cache controls, and silently ignored directives including mod_evasive, mod_userdir, mod_proxy, mod_ratelimit and mod_status, annotated to show that the third column produces no error at all

    A quick way to list the module guards a file depends on:

    grep -n 'IfModule' /home/example/public_html/.htaccess
    3:<IfModule mod_rewrite.c>
    19:<IfModule mod_headers.c>
    27:<IfModule mod_evasive20.c>

    The third one is the finding. On Apache the guard would skip the block if the module were absent; on LiteSpeed the guard passes or fails on a module list you do not control, and the directives inside it are ignored either way.

  5. Compare against what Apache would have loaded. If you are trying to work out which module a directive came from, ask the Apache binary, which is still installed on a cPanel server even while LiteSpeed serves traffic.

    httpd -M 2>/dev/null | grep -E 'evasive|ratelimit|proxy_module|userdir'

    Any module listed here was available on Apache and is not doing the same job under LiteSpeed. Anything absent was never working in the first place.

  6. Re-home the directives that do not survive. ModSecurity rules move to the server or virtual host ModSecurity configuration, covered in ModSecurity on LiteSpeed. Rate limiting and connection throttling move to the per-client throttling settings in WebAdmin. SSLRequireSSL becomes a rewrite:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
  7. Know what needs a restart. Editing .htaccess needs nothing; the change is live on the next request. Editing a virtual host or the server configuration needs a graceful restart, which drains existing workers rather than dropping connections.

    /usr/local/lsws/bin/lswsctrl restart
    [OK] Send SIGUSR1 to 1148

Validate it works

Prove each category of directive with a request. A saved file is not evidence.

curl -sI https://example.com/ | grep -iE 'x-frame-options|strict-transport|cache-control'
curl -sI -H 'Accept-Encoding: gzip' https://example.com/ | grep -i 'content-encoding'
curl -sI https://example.com/wp-content/uploads/ | head -1
curl -sI https://example.com/old-page/ | grep -iE 'HTTP/|^location:'

Expected, in order: the headers your mod_headers block sets, gzip negotiated, a directory that refuses to list, and a redirect that resolves:

x-frame-options: SAMEORIGIN
strict-transport-security: max-age=31536000
content-encoding: gzip
HTTP/2 403
HTTP/2 301
location: https://example.com/new-page/

An empty result from the first command is the whole point of this article: the Header set line is in the file, the file parsed, and the header is not on the response. Work backwards through the two gates in that order.

Troubleshooting

Nothing in the file has any effect. Both gates are suspects, and they are cheap to eliminate. Check autoLoadHtaccess and enable in the vhost rewrite block first, then AllowOverride. If both are correct, confirm you are editing the document root LiteSpeed resolved and not a stale directory left behind by a migration.

A header appears on the homepage but not on a 404 or a redirect. Header set defaults to the onsuccess condition, which only attaches to 2xx and 3xx responses. Add always — Header always set X-Frame-Options SAMEORIGIN — and re-test against a URL that returns 404.

A new deny rule does not block anything, but only sometimes. LSCache answered from cache before the access rule was evaluated. Purge the cache for that path, or test with a cache-busting query string, then re-run the curl. This is also why a 403 you added can appear to work in a private browser window and not in a logged-out one.

php_value produces no change. Confirm the handler. If the account runs a suPHP-style handler rather than LSAPI, the directive is not applied and the setting belongs in php.ini. On cPanel, MultiPHP INI Editor writes the equivalent value for the account.

A virtual host change made in WebAdmin has no effect. Configuration outside .htaccess is read at startup. Run /usr/local/lsws/bin/lswsctrl restart or use Graceful Restart in the console, then repeat the request-level test rather than re-reading the file.

When this is the wrong approach

.htaccess is a per-directory override mechanism, and treating it as the site’s primary configuration has a cost on any server. If a document root carries hundreds of rules, or the same block is duplicated across dozens of accounts, move it into the virtual host configuration, where it is parsed once at startup instead of on the path of every request. If you are running OpenLiteSpeed rather than Enterprise, rewrite rules belong in the vhost rewrite block and most of this reference does not transfer. And .htaccess is a poor place for a firewall: rate limiting, bot filtering and request inspection belong to a ModSecurity ruleset or an edge service, both of which report what they blocked. The authoritative directive list for each release is in the LiteSpeed documentation.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.