OpenLiteSpeed htaccess setup

One of the most alluring features of OpenLiteSpeed is that it is highly compatible with Apache, so web admins migrating from Apache web server to OpenLiteSpeed will not have to spend much time converting their configuration. When using the Apache web server, .htaccess files (also called “distributed configuration files”) are used to specify configuration on a per-directory basis, or more generally to modify the behavior of the Apache web server without having to access virtual hosts files directly (this is usually impossible for example, on shared hosts).

Although .htaccess files were developed with Apache in mind, OpenLiteSpeed also has the ability to read them. This makes OpenLiteSpeed able to act as a drop in replacement for those wishing to migrate from Apache. In order for OpenLiteSpeed to recognize .htaccess files, the pertinent setting must be enabled. In this tutorial, you will see how to enable htaccess support in OpenLiteSpeed on a Linux system.

In this tutorial you will learn:

  • How to change listening port for OpenLiteSpeed web server
  • How to enable HTTP or HTTPS for the listening port
OpenLiteSpeed change port
OpenLiteSpeed change port
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Debian Linux or Red Hat Enterprise Linux based Linux distro
Software OpenLiteSpeed and LiteSpeed web servers
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

OpenLiteSpeed htaccess setup step by step instructions

Twitter icon Follow on Twitter for the latest tips and tricks about Linux!

The .htaccess file gets placed into a directory, and allows administrators to specify instructions that apply to that directory.

OpenLiteSpeed only supports mod_rewrite rules from Apache’s htaccess files. Other rules inside of the files will not be recognized, and will have to be manually configured within OpenLiteSpeed.

Follow the step by step insructions to configure OpenLiteSpeed to recognize your website’s htacces files:

  1. Get started by navigating to the OpenLiteSpeed web admin panel located at https://localhost:7080/login.php and log in with your admin user name and password. In case you have not yet configured one, see our guide on OpenLiteSpeed default password.
    Log in to the OpenLiteSpeed web admin
    Log in to the OpenLiteSpeed web admin
  2. If you would like to enable htaccess support across the entire web server, head to Server Configuration > General > Rewrite Control. Change the ‘Auto Load from .htaccess’ option to ‘Yes’ as seen below.
    Turning on server wide htaccess support
    Turning on server wide htaccess support
  3. If, instead, you would only like a particular virtual host to recognize htaccess files, head over to Virtual Hosts > Select your virtual host > Rewrite. Change the ‘Enable Rewrite’ and ‘Auto Load from .htaccess’ options both to ‘Yes’ as seen below.
    Turning on virtual host support for htaccess files
    Turning on virtual host support for htaccess files
  4. Do not forget that you need to perform a graceful restart in order for the new changes to take effect. Afterwards, your web server or virtual host (depending on which configuration option you chose) will recognize the rewrite rules within the .htaccess files in each directory.

    Performing a graceful restart in OpenLiteSpeed
    Performing a graceful restart in OpenLiteSpeed

Closing Thoughts

In this tutorial, we saw how to enable and disable the .htaccess file for an OpenLiteSpeed server on a Linux system. This configuration file allows for simple and granular rules to be applied on a per directory basis, but is slower than applying your rules directory to the OpenLiteSpeed virtual hosts settings. Still, on shared hosting or in other situations, it proves to be the most viable method for applying rewrite rules.

Comments and Discussions
Linux Forum