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
.htaccessactually uses, split into native, different-scope, and silently-ignored. - Confirm that the virtual host reads
.htaccessat all, which is the single most common reason a file appears to be completely ignored on a standalone LiteSpeed install. - Check that
AllowOverridepermits 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.htaccessthe 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.confand the per-account vhost includes, and.htaccessloading 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_valueandphp_flagdepends 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 module | Status on LiteSpeed | What to know |
|---|---|---|
RewriteEngine, RewriteRule, RewriteCond, RewriteBase | Native | Parsed per request. WordPress permalink blocks work unchanged. |
Flags [L], [R=301], [QSA], [NC], [E=VAR:value] | Native | Including chained conditions and backreferences. [E=] sets an environment variable LiteSpeed can act on. |
Header set / add / append / unset (mod_headers) | Native | The always and onsuccess conditions are honoured. Without always, the header is only added to successful responses. |
ExpiresActive, ExpiresByType, ExpiresDefault | Native | Same syntax and same computed Cache-Control. |
mod_deflate / gzip output filters | Native | LiteSpeed compresses by its own configuration; the filter directives do not conflict with it. |
Require all granted / Require all denied (mod_authz_core) | Native | The 2.4 access-control syntax. |
Order, Allow from, Deny from | Native | The legacy 2.2 syntax is still understood, which matters for older WordPress hardening snippets. |
AddType, AddHandler, AddDefaultCharset (mod_mime) | Native | Handler assignment is how cPanel switches PHP versions per directory. |
SetEnvIf, SetEnvIfNoCase, BrowserMatch | Native | Useful for pairing with Header set ... env= conditions. |
ErrorDocument | Native | Both the path form and the inline-text form. |
DirectoryIndex | Native | |
Options -Indexes, Options +FollowSymLinks | Native | Subject to AllowOverride Options, exactly as on Apache. |
Redirect, RedirectMatch | Native | |
<Files>, <FilesMatch>, <Directory>, <IfModule> | Native | Container contexts nest as expected. |
php_value, php_flag | Handler-dependent | Applied 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. |
LimitRequestBody | Different scope | The server-wide and per-vhost request body limit wins. A per-directory value cannot raise the ceiling above it. |
ModSecurity Sec* directives | Different scope | LiteSpeed runs its own ModSecurity engine, enabled per server or per virtual host, not from .htaccess. |
CacheEnable, CacheRoot (Apache mod_cache) | Ignored | These are not valid in .htaccess on Apache either. LiteSpeed caching is LSCache, which is a different mechanism. |
ProxyPass, ProxyPassReverse (mod_proxy) | Ignored | Proxying belongs in the virtual host’s external application and context configuration. |
DOSPageCount, DOSSiteCount (mod_evasive) | Ignored | LiteSpeed has its own per-client throttling settings in the server and vhost security configuration. |
UserDir (mod_userdir) | Ignored | |
SetOutputFilter RATE_LIMIT (mod_ratelimit) | Ignored | Bandwidth shaping is a LiteSpeed throttling setting, not an .htaccess directive. |
SetHandler server-status (mod_status) | Ignored | LiteSpeed reports status through WebAdmin and its own real-time report. |
SSLRequireSSL | Ignored | Force HTTPS with a RewriteCond %{HTTPS} !=on rule instead, which is native. |
<IfModule LiteSpeed> | LiteSpeed only | Apache skips the block; LiteSpeed enters it. This is how you keep a file portable across both. |
CacheLookup on, CacheDisable | LiteSpeed only | LSCache controls. They belong inside an <IfModule LiteSpeed> guard. |
RewriteRule ... [E=cache-control:max-age=N] | LiteSpeed only | Sets 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.
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
-
Confirm LiteSpeed is the server answering, and that it is running. The response header proves the server family;
lswsctrlproves the daemon state.curl -sI https://example.com/ | grep -i '^server:' /usr/local/lsws/bin/lswsctrl statusserver: LiteSpeed litespeed is running with PID 1148. -
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 1If 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. -
Check the
AllowOverridescope for the document root. LiteSpeed reads this from the Apache configuration it inherited.grep -r -n 'AllowOverride' /etc/apache2/conf/httpd.confExpect
AllowOverride Allfor a normal cPanel account.Nonemeans no.htaccessis consulted anywhere under that directory. -
Audit the file against the three categories before you debug anything. Read your
.htaccessonce 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.A quick way to list the module guards a file depends on:
grep -n 'IfModule' /home/example/public_html/.htaccess3:<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.
-
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.
-
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.
SSLRequireSSLbecomes a rewrite:RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] -
Know what needs a restart. Editing
.htaccessneeds 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.