BETANot production ready yet. Testers wanted: apply · report a bug
KarnakPanel
Websites & PHP / .htaccess on OpenLiteSpeed

Your .htaccess is probably not being read.

OpenLiteSpeed can honour .htaccess files, but only when the server is told to, and only for part of the syntax. Everything else is accepted in silence: no error, no log line, no effect. This page is the diagnosis, the compatibility list, and where the rest of the rules belong.

The cause

There are two switches, and both are off by default.

Apache reads .htaccess on every request. OpenLiteSpeed does not: it is a performance decision, and it catches almost everyone moving from Apache or shared cPanel hosting.

  • Per-vhost override. The vhost needs Allow Override enabled before the server looks at the file at all. With it off, an .htaccess in the document root is an ordinary, inert file.
  • Per-panel behaviour. Hosting panels differ. Some enable the override and let the server parse the file; others import the file into the vhost configuration when you save it. Ours does the second, which is why editing .htaccess here needs a server reload before anything changes.
  • The syntax subset. Even with the override on, OpenLiteSpeed implements part of the format. Directives outside that part are not rejected — they are ignored, which is the failure mode that wastes an afternoon.
Prove it first

Sixty seconds, one rule.

Before changing anything else, find out whether your file is read. Put this at the top of the document root's .htaccess, save, reload the server, then ask for the path.

At the top of .htaccess
# one rule that can only work if the file is read
 RewriteEngine On
 RewriteRule ^htaccess-test$ /?htaccess=ok [R=302,L]
Then, from anywhere
# a 302 with your query string means the rule ran
$ curl -sI https://example.com/htaccess-test | head -3
location: https://example.com/?htaccess=ok
Read the result carefully. A 302 to /?htaccess=ok means the file is read and rewriting works. A 404 means the rule never ran — so the problem is the switch, the reload, or the panel import, not your syntax. A 500 means the syntax was parsed and rejected, which is the one case where the directive itself is at fault.
Compatibility

What OpenLiteSpeed honours.

Measured on a live OpenLiteSpeed server, not copied from a compatibility table. If a directive is in the right-hand column, rewriting it will not help: it belongs somewhere else.

DirectiveOpenLiteSpeedWhat to do instead
RewriteEngine, RewriteCond, RewriteRuleWorksNothing. This is the part worth keeping in the file.
Header set / Header always setWorksNothing. Security headers sent this way do reach the browser.
Require all deniedWorksNothing, for denying a path.
Options (e.g. -Indexes)IgnoredDirectory behaviour is a vhost setting, set through the panel, not a file in the directory.
<Files>, <FilesMatch>, <Directory>IgnoredUse a path rewrite instead — a RewriteRule matching the name, returning 403 or 404.
php_value, php_flag, php_admin_valueIgnoredSet PHP per domain in the panel, or per directory through .user.ini, which is how PHP-FPM expects it.
AuthType, AuthUserFile, Require valid-userIgnoredPassword protection is a panel feature, or a vhost rule. The Apache syntax has no effect.

"Ignored" is the important word. Apache would refuse to start with an unknown directive; OpenLiteSpeed reads past it, so a file full of unsupported rules looks perfectly correct and does nothing.

Diagnosis

Four reasons it "does not work".

In the order worth checking.

  • 1 · The override is off. The file is inert. On a managed server this is the host's setting; on your own, it is Allow Override in the vhost configuration.
  • 2 · Nothing has been reloaded. OpenLiteSpeed caches this configuration. If your panel imports .htaccess into the vhost, the change lands when the import runs and the server reloads — not when you save the file. This site is exactly that model: edit, reload, then test.
  • 3 · The directive is unsupported. The matrix above. No error is produced, so the only way to find out is to test for the effect rather than the absence of an error.
  • 4 · The rule is in the wrong scope. A rule in a parent folder above the document root is not applied to the site the way Apache would apply it. Put per-site rules in the document root's file, and site-wide rules in the vhost through the panel.
Case study

What this site's own .htaccess contains.

Five lines that work, and one that had to live in the vhost. It is a small enough file to read in full, and every behaviour below can be checked against this site right now.

karnakpanel.com/.htaccess
 RewriteEngine On
 RewriteCond %{HTTPS} !=on
 RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
 Header always set Strict-Transport-Security "max-age=63072000"
  • The redirect is a rewrite, not a directive. It could have used a one-line redirect statement; rewrite syntax is the part OpenLiteSpeed definitely implements, so it is what stayed.
  • The header is sent by the same file. curl -sI https://karnakpanel.com/ returns strict-transport-security: max-age=63072000, which is that line and nothing else.
  • The protection for dotfiles is in the vhost, not the file. Blocking .env, .git and their relatives would normally be a <Files> block. That syntax is ignored by OpenLiteSpeed, so the rule is a path rewrite in the vhost instead: curl -s -o /dev/null -w "%{http_code}" https://karnakpanel.com/.htaccess returns 403.
  • There is no php_value line. PHP limits are set per account and per domain in the panel, where they are enforced by the PHP master rather than by a file in a directory.

That is the whole argument of this page in one file: the rules that survived are the subset OpenLiteSpeed implements, and the rule that could not survive moved into the vhost.

The alternative

Why not just use Apache?

Legitimate question, and the answer is not "because it is faster".

  • The compatibility layer is the price of the performance model. OpenLiteSpeed keeps configuration in memory and reads it at startup; per-directory files are the opposite design. You can have the file or the model, and Apache-compatible per-directory config is not what this server was built around.
  • The .user.ini route is real, and underused. Per-directory PHP settings have a supported, documented mechanism that works with PHP-FPM. It is a better target than php_value in .htaccess on any FPM setup.
  • A panel makes the vhost reachable. The honest reason the subset is fine here: the rules that need root-level scope have a UI, and the rules that do not fit in .htaccess have somewhere to go.
Limits

What this page does not claim.

Kept short, because the compatibility table above is the substance.

The matrix is a subset list, not a specification. It covers the directives people actually copy from Apache tutorials. Anything not listed should be tested for its effect, not assumed.
Panel behaviour varies. An override-enabled OLS host and an import-into-vhost host fail in different ways. The 60-second test tells you which one you have.
This is not Apache. Files written for shared hosting will need editing, and some of them will need moving out of the file entirely.
KarnakPanel writes the vhost for you. That is convenient, and it is also why editing rules bypasses the panel at your own risk. Beta software: test on a spare domain first.
Questions

The short ones.

Answers that fit in a paragraph.

Does OpenLiteSpeed support .htaccess at all?

Yes, partially, and only when the vhost allows override. Saying it does not support .htaccess is a common shorthand that sends people looking for the wrong fix. Saying it supports .htaccess fully is worse, because the ignored directives give no error.

Why did my rules work before the move?

Because Apache parsed them, or because your old panel enabled override. On this stack they arrive only after the import and reload, and only the rewrite and header parts arrive at all.

Can I use .htaccess for password protection?

Not with the Apache directives. Use the panel's own protection, or a vhost rule. AuthType and its neighbours are in the ignored column.

Where do PHP settings go?

php_value in .htaccess is ignored here. Set the PHP version and limits per domain in the panel, and per directory with .user.ini. The hosting page covers what the panel sets per account.