This is an old revision of the document!


Rewrite rules LSWS 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 the 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 implementation to balance the easy rewrite rules migration and speed.

One of the differences is about global rewrite case.

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

With Litespeed, only wrapped in a <Directory> works. Use of DirectoryMatch, Files and FilesMatch does not work - the mod_rewrite rules do not trigger.

Tested using a simple rewrite rule:

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

This can be easily tested in a cPanel environment by switching between LSWS and Apache.

Actually, LSWS works just as designed. Not like Apache, everything is re-evaluated at run-time for each request. The list of server level rewrite rules are pre-computed and executed at run-time before directory matching files and filesmatch contexts are evaluated. Only <Directory> context can be pre-processed.

  • Admin
  • Last modified: 2019/03/28 17:51
  • by Jackson Zhang