Rewrite Rules LiteSpeed Web Server vs. Apache

As a drop-in replacement, LSWS tries to match Apache rewrite rules as much as it can. Most of the time, you will find LSWS and Apache act the same way. However, to maximize speed and performance, there are some minor differences in rewrite rules implementation between LSWS and Apache by design. Also, we constantly review customer feedback on such rewrite implementations to balance easy rules migration and any performance gains.

Global Rewrite

One of the differences is with the processing of global rewrite rules.

With Apache, when placing mod_rewrite files into the main httpd.conf, they will operate as expected, so long as they are wrapped in <Files>, <FilesMatch>, <Directory> or <DirectoryMatch> tags.

With Litespeed, only <Directory> will trigger the rewrite rules. Rules wrapped in DirectoryMatch, Files and FilesMatch tags do not trigger.

In a cPanel environment, you can test this behavior with a simple rewrite rule, by switching between LSWS and Apache:

RewriteRule ^(.*) http://example.com [L,R=301]

Why is this so? Apache reevaluates everything at runtime for each request. LiteSpeed Web Server, however, precomputes the list of server-level rewrite rules before executing them at runtime, and only the <Directory> context can be preprocessed. Preprocessing happens before the DirectoryMatch, Files and FilesMatch contexts can be evaluated.