2

I use the following rewrite on my site and it worked fine in shared server.

 RewriteEngine On
 <Files .*> 
     Order Deny,Allow   
     Deny From All
 </Files>
 <Files ~ "^\.ht">
     order allow,deny
     deny from all
     satisfy all
 </Files>
 <FilesMatch "^php5?\.(ini|cgi)$">
     Order Deny,Allow 
     Deny from All 
     Allow from env=REDIRECT_STATUS 
 </FilesMatch> 
 AddDefaultCharset utf-8
 Options All -Indexes
 RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|ico|txt|pdf|xml)$ [OR]
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -s [OR]
 RewriteCond %{REQUEST_FILENAME} -l [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^.*$ - [NC,L]
 RewriteRule ^.*$ public_html/index.php [NC,L]   

But now it shows the following error.

404 Not Found
The resource requested could not be found on this server!
Powered By LiteSpeed Web Server
LiteSpeed Technologies is not responsible for administration and contents of this web site!

How can I fix this error?

It acts differently on LiteSpeed?

Jost
  • 1,549
  • 12
  • 18
navid
  • 823
  • 2
  • 11
  • 29
  • To troubleshoot rewrite in litespeed, enable rewritelogging (add 'RewriteLogLevel 9' in vhost httpd.conf and restart lsws to activate the change) and then you can check the `REWRITE` entries in error_log. – Mark Baker Oct 11 '13 at 08:44
  • @MarkBaker : my site is on a shared server. – navid Oct 11 '13 at 08:50

5 Answers5

1

Are you using Litespeed Enterprise or Openlitespeed?

OpenLitespeed cannot work with the .htaccess file, you need to configure it via web admin: Edit virtual host -> Rewrite

Litespeed Enterprise should work with the htaccess file, make sure you configure it to work with it:

Edit virtual host -> Rewrite -> Enable Rewrite: NO

Alum
  • 26
  • 2
1

Openlitespeed support with .htaccess, but must setting in Openlitespeed admin panel. From Openlitespeed admin panel click Virtual Host, Select your vhost. Klik Rewrite Tab, select 'Yes' in Rewrite Control->Enable Rewrite. Point your file in Rewrite Rules, for example /usr/local/lsws/web/.htaccess, and restart litespeed.

If you use centos, you can use auto install script with multi vhost support from https://github.com/tujuhion/openlitespeed-centos-autoinstall

  • 1
    These are my settings- Virtual Host - Rewrite - enable rewrite - yes autoload from .htaccess - not set rewrite rules - not set i dont think it is reading the htacess file present in /usr/local/lsws/domani/html/.htaccess am i doing something wrong my https site is not working /404 (http is fine), wordpress permalinks are not working and wp-admin folder is 404 (wp-admin/index.php is working) – Shitij Feb 05 '19 at 09:00
1

In my experience OpenLiteSpeed loads most of rewrites correctly but you have to prepend the rules with "/?", because of the optional initial slash.

FilesMatch rules need to be set at context or rewrite level, please see here:

https://openlitespeed.org/kb/access-control/#Controlling_Access_to_Files

santamanno
  • 626
  • 4
  • 12
0

for each version of php in litespeed panel; you must add a seperate script-handler and external-app, finally gracfully restart your lsws service.

rezshar
  • 570
  • 1
  • 6
  • 20
0

If you are in OpenLiteSpeed after adding any rule you need to do a webserver restart. use this command to restart your webserver.

systemctl restart lsws

More you can also add from the rewrite rules in web admin.