AutoLoad .htaccess with OpenLiteSpeed

You are here:
< Back

Since v1.4.38, OpenLiteSpeed supports the ability to autoload .htaccess from directories and subdirectories automatically. The old ways of adding rewrite rules manually via the WebAdmin Console or vHost config will continue to work, but if you’re looking to manage your rewrite rules from .htaccess directly, we now have a solution for it.

To enable .htaccess autoload within your main directory, add this to your vHost config:

rewrite  {
  enable                  1
  autoLoadHtaccess        1

This will pick up the .htaccess file from the VirtualHost’s root directory.

Since v1.5.4, AutoLoad .htaccess has been improved and does not need settings defined below to read .htaccess in subdirectories, just the setting above will allow Openlitespeed to read .htaccess in all directories and subdirectories in the vHost. However, .htaccess files in the Subdirectories will only be loaded once the directory is accessed(using HTTP).

If you also have a subdirectory, where you would like OpenLiteSpeed to look for .htaccess files, add a context via your vHost config:

context /dir/ {
allowBrowse             1

This will allow OpenLiteSpeed to browse the directory defined in the context and pick up .htaccess from there as well. You’ll need to add a new context for each subdirectory.

OpenLiteSpeed currently only supports mod_rewrite rules from Apache, so before making it read the .htaccess files, please convert
them to Apache’s mod_rewrite format. Some examples are on this page. Remember to restart OLS, after making changes to your rewrite files, so that it can read the new ones.