LiteSpeed Enterprise
LiteSpeed Web Server (Enterprise) reads Apache's configuration and .htaccess files, including mod_rewrite rules. Serve Exponential exactly as with Apache: ./console exp:setup:htaccess --apply (or copy .htaccess_root to .htaccess), with PHP through LiteSpeed's LSAPI. Nothing else is needed.
OpenLiteSpeed
The open source edition reads only the rewrite rules of a .htaccess, only when autoLoadHtaccess is on, and only after a restart when the file changes. The kernel's example doc/eng-us/examples/web-servers/openlitespeed-vhost.conf puts the rules in the virtual host instead, where they are read once.
- Define the virtual host and map it to the listeners for ports 80 and 443 in WebAdmin, or in /usr/local/lsws/conf/httpd_config.conf.
- Put the file at /usr/local/lsws/conf/vhosts/example.com/vhconf.conf and replace example.com, /var/www/example.com, the certificate paths, the lsphp path (lsphp83 for PHP 8.3) and extUser and extGroup (the owner of the installation's files).
- Make a graceful restart: /usr/local/lsws/bin/lswsctrl restart, or Graceful Restart in WebAdmin.
Notes on the example
- Every pattern starts with ^/?, so the same rules work in the virtual host and in a context.
- The context blocks for /.git/, /settings/, /vendor/ and /var/log/ are defense in depth: if the rewrite rules were ever switched off, the contexts still refuse those paths.
- extraHeaders adds the kernel's default security headers.
- For certificate challenges, use the server's own certificate support, or add a rule that serves /.well-known/acme-challenge/ directly after the dot rule.
Note: The OpenLiteSpeed example was not run on LiteSpeed by the project; its rewrite rules answered every test request as expected in Apache's mod_rewrite.
The page cache
Both editions can keep whole pages and answer anonymous visitors and crawlers without running PHP. It ships switched off, as commented blocks in .htaccess_root, in litespeed-page-cache.conf and in the OpenLiteSpeed example. Remove the comment signs, then restart.
Only a GET or HEAD without a query string, from a visitor with no session or sign-in cookie, to an address that is not an administration, user, shop or editing view is stored, for 120 seconds. A cached answer carries X-LiteSpeed-Cache: hit.