Blog image

OpenLiteSpeed v1.4.38 has been released!

Today we dedicate this post to one of the best releases of OpenLiteSpeed. Since the beginning of time all of us have had issues when it comes to rewrite rules and OpenLiteSpeed. But that is no more. With this release we’ve a very important feature to discuss that is going to change life of many people.

.htaccess Autoload

As of OpenLiteSpeed version v1.4.38 and above, we’ve a special feature called .htaccess autoload. This works slightly differently than Apache, but there is good news: we can now copy the exact same rules from Apache, and with autoload this now applies to sub-directories as well. We will discuss this below.

How it works?

Apache and LiteSpeed Enterprise can dynamically load .htaccess files, which means if you make any changes to your .htaccess rules, they will be reloaded in real time when that url/directory is accessed again.

However, OpenLiteSpeed autoload will load your .htaccess rules only when the directory/url is first accessed. So, for example, there is a WordPress installation at https://cyberpanel.net/wordpress, and on the filesystem this maps to /home/cyberpanel.net/public_html/wordpress. Thus the .htaccess file from this directory will be loaded when you first visit this URL.

Later, if you make any changes to your .htaccess, all you need to do is restart OpenLiteSpeed and your updated rules will take effect.

How to activate .htaccess autoload?

If you are using CyberPanel, you first need to upgrade OpenLiteSpeed, so that you are using v1.4.38.

yum upgrade openlitespeed

This will successfully upgrade you to the latest version. Now open a website launcher in CyberPanel and put this at end of your vhost conf:

rewrite  {
  enable                  1
  autoLoadHtaccess        1

And that is all. You then don’t need to worry about conversion of your rewrite rules from Apache to OpenLiteSpeed. Please keep in mind that OpenLiteSpeed only supports the following rewrite directives:

  • RewriteRule
  • RewriteCond
  • RewriteBase
  • RewriteFile (LiteSpeed specific)

If sometimes your rules are not working, it means you have not restarted OpenLiteSpeed. For example, you have freshly installed WordPress and visited your site. OpenLiteSpeed will load .htaccess, but there will be no rewrite rules there. Later you decide to enable permalinks, and now your rewrite rules will be populated, but OpenLiteSpeed will not honor them until you restart the server.

How to debug if something does not work as expected?

If your rewrite rules do not work as you expect them to, you can turn on rewrite logging. In your vhost conf add:

rewrite  {
  enable                  1
  autoLoadHtaccess        1
  logLevel                9

logLevel 9 will give you the maximum amount of logging. After that, on command line you can grep any rewrite related errors:

tail -f /usr/local/lsws/log/error.log | grep ERROR


tail -f /usr/local/lsws/log/error.log | grep REWRITE

If you get an error saying some directive is not supported, you can safely remove those directives and restart OpenLiteSpeed.

Note: CyberPanel by default will enable .htaccess autoload.

Author's page
Cyber Panel

Leave a Reply