LiteSpeed

.htaccess on LiteSpeed: what works, what does not and how to fix rules

How LiteSpeed Web Server handles .htaccess files: supported directives, rewrite rules, PHP settings, unsupported modules and how to debug rules that do nothing.

IntermediatecPanel hosting with LiteSpeed3 min read

LiteSpeed Web Server is built to read Apache's .htaccess files, so redirects, rewrites and security rules written for Apache keep working. A few things behave differently, though, and knowing them saves hours when a rule seems to be ignored.

Before you start

  • Access to your site's files through cPanel → Files → File Manager (enable Show Hidden Files in Settings) or FTP.
  • A copy of the current .htaccess before editing.

What works the same as Apache

  • mod_rewrite: RewriteEngine, RewriteCond, RewriteRule, including WordPress permalinks.
  • Redirects: Redirect 301, RedirectMatch.
  • Access control: Require all denied, Require ip, and older Order/Deny/Allow.
  • Headers and caching: Header set, ExpiresByType, AddType.
  • Error pages: ErrorDocument 404 /404.html.
  • Password protection: AuthType Basic with .htpasswd.
  • Compression: mod_deflate rules are accepted; LiteSpeed also compresses on its own.

Example: force HTTPS and www

RewriteEngine On
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]

cPanel also has a one-click option (see forcing HTTPS in cPanel).

What is different

ItemOn LiteSpeed
php_value / php_flagSupported with LSAPI, but CloudLinux PHP Selector options are the preferred place (see PHP options).
Options +Indexes, -MultiViewsSupported.
mod_security rules in .htaccessIgnored; ModSecurity is configured server-side.
Rare Apache modules (mod_perl, mod_python)Not supported.
<IfModule mod_xxx.c> blocksEvaluated as if the module is present for supported modules, such as rewrite and headers.
LSCache directives (CacheLookup, E=cache-control)LiteSpeed-only; Apache ignores them.

Debug a rule that does nothing

  1. Check the file location. Rules in public_html/.htaccess apply to the main domain; addon domains have their own document root and file.
  2. Check rule order. Place your redirects above the WordPress block (# BEGIN WordPress), which ends processing for most URLs.
  3. Clear caches. LiteSpeed caches pages and browsers cache 301 redirects. Test in a private window and purge LSCache.
  4. Wait a moment. LiteSpeed re-reads changed .htaccess files quickly, but not always instantly.
  5. Look at the error log. cPanel → Metrics → Errors shows syntax problems.

Warning: A single typo in .htaccess can cause a 500 Internal Server Error for the whole site. If that happens, rename the file to .htaccess.bak to get the site back, then fix the rule.

Troubleshooting

Redirect loop after forcing HTTPS

A CDN or proxy terminates SSL and sends plain HTTP to the server. Check %{HTTP:X-Forwarded-Proto} instead of %{HTTPS}, or use the CDN's own redirect.

WordPress permalinks give 404

Go to Settings → Permalinks and click Save to rewrite the WordPress block.

Frequently asked questions

Do I need to restart LiteSpeed after editing .htaccess?

No. LiteSpeed detects changes automatically. Customers on shared hosting cannot restart the server and do not need to.

Can I use Nginx rules?

No. LiteSpeed understands Apache syntax, not Nginx configuration. Convert Nginx rules to mod_rewrite.

Where do I put rules for an addon domain?

In the .htaccess file inside that domain's own document root, shown in cPanel → Domains. Rules in public_html do not apply to addon domains with a separate root.

Can I block an IP address in .htaccess?

Yes, with Require not ip inside a RequireAll block. For attacks across many sites, ask support to block the IP in the firewall instead.

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.