RemarkableCloud

.htaccess & Rewrite Rules with LiteSpeed

How .htaccess works on LiteSpeed, how to write rewrite rules, and common patterns for WordPress, redirects, and security hardening.

LiteSpeed is fully compatible with Apache .htaccess files: the same syntax works without modification. This guide covers the most common patterns.

How LiteSpeed handles .htaccess

LiteSpeed reads .htaccess files natively using its own engine (not Apache’s mod_rewrite). Compatibility is near-100% for standard directives. The main differences:

  • Rules process faster than Apache (LiteSpeed caches parsed rules)
  • All standard RewriteRule, RewriteCond, RedirectPermanent, and Header directives work identically
  • Some obscure Apache-specific modules have no equivalent: but these are rarely used in practice

WordPress rewrite rules

The standard WordPress .htaccess works unchanged on LiteSpeed:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If WordPress isn’t generating this automatically: WordPress Admin → Settings → Permalinks → click Save Changes (triggers .htaccess regeneration).

Common redirects

Force HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Redirect www to non-www

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

Redirect non-www to www

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

Redirect a specific page

Redirect 301 /old-page/ https://yourdomain.com/new-page/

Redirect entire old domain to new domain

RewriteEngine On
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]

Security hardening

Block access to sensitive files

<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|sql|bak)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

Protect wp-config.php

<files wp-config.php>
    Order allow,deny
    Deny from all
</files>

Block XML-RPC (reduces brute-force attacks on WordPress)

<Files xmlrpc.php>
    Order Deny,Allow
    Deny from all
</Files>

Disable directory browsing

Options -Indexes

PHP settings via .htaccess

Override php.ini values per directory:

php_value memory_limit 512M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_flag display_errors off
If your server uses PHP-FPM (standard on LiteSpeed with cPanel), php_value directives in .htaccess are handled by LiteSpeed's PHP handler, not Apache's. They still work, but the syntax must be correct: a typo causes a 500 error rather than being silently ignored.

Debugging .htaccess issues

Enable rewrite logging temporarily:

RewriteLog /tmp/rewrite.log
RewriteLogLevel 3

Check the log at /tmp/rewrite.log to see which rules are matching and why. Remove after debugging.

Or test from the command line:

# Test if a URL would match a rewrite rule
curl -I https://yourdomain.com/test-url

Check the Location: header in the response to see where the redirect is going.

Still stuck? Ask a human, we answer in minutes.