OpenLitespeed htaccess

5.5k views Asked by At

I'm a new user of OpenLitespeed web server. Previously I used Apache for my web server. Now, I'm getting confused about .htaccess for security purpose in OpenLitespeed.

Below my .htaccess rule works great in Apache

IndexIgnore *.css *.js *.png *.jpg
Options -Indexes
ErrorDocument 400 index.php
ErrorDocument 403 index.php
ErrorDocument 404 index.php
ErrorDocument 500 index.php

<Files ~ "\.optl$">
Order allow,deny
Deny from all
</Files>

How can I use this rule in OpenLiteSpeed Web Server? Thank you

3

There are 3 answers

0
Eric On

For OpenLitespeed web server.
You can set ErrorDocument through Virtual Host -> General -> Customized Error Pages
Error Code support all your needed. e.g. 300 ~ 505 which include 400,403,404,500.

You can set Index file though Virtual Host -> General -> Index Files

Both above rules probably not supported from "another way", that's why you need to setup from web admin. "another way" only support rewrite rules.

0
Yanwar Purnama On

In openlitespeed you must point your .htaccess file in virtual host. From openlitespeed admin Klik Virtualhost -> Select your virtualhost, in tab Rewrite check to 'Yes' for Enable Rewrite, and rewrite rule insert your path of file .htaccess for example /usr/local/lsws/yourweb/.htaccess

And restart your openlitespeed server

/usr/local/lsws/bin/lswsctrl restart

You can use scripts auto install with support multi vhost from https://github.com/tujuhion/openlitespeed-centos-autoinstall

0
harrrrrrry On

I am not sure this is the correct answer, but I put it here in case you need it:

OpenLitespeed supports .htaccess in another way. You can copy the rewrite rules from the .htaccess and paste into OpenLiteSpeed admin console:

https://serverfault.com/questions/538249/does-openlitespeed-support-apache-rewrites

Update: Yes I just tested it as I met this issue now. It did work.