Htaccess On CloudLinux And LiteSpeed

<IfModule Litespeed>
    <Files ~ (\.py$)>
        SetHandler None
    </Files>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/static/
    RewriteCond %{REQUEST_URI} !^/media/
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /passenger_lite/loader.py/$1 [P,L]
    PassengerAppRoot /path/to/your/django/project
    PassengerBaseURI /your/app/base/uri
    PassengerPython /path/to/your/python/executable
</IfModule>

 

Here is an explanation of each of the RewriteCond directives in the example configuration:

  • RewriteCond %{REQUEST_URI} !^/static/: This directive checks whether the requested URI does not start with "/static/". If this condition is met, the subsequent RewriteRule directive will be applied.

  • RewriteCond %{REQUEST_URI} !^/media/: This directive checks whether the requested URI does not start with "/media/". If this condition is met, the subsequent RewriteRule directive will be applied.

  • RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f: This directive checks whether the requested file does not exist in the document root of the web server. If this condition is met, the subsequent RewriteRule directive will be applied.

This configuration tells the LiteSpeed web server to use the CloudLinux Passenger module to serve your Django application. Note that this configuration assumes that your application's static files are located in a directory named "static" and that your media files are located in a directory named "media" at the root of your application.

You may need to adjust the configuration to match the specific setup of your Django application. It's always a good idea to consult the official documentation for your web server and application server to ensure that you are configuring them correctly.


TAGS

htaccess cloudlinux litespeed