Rewrite rules in native format within virtualHost

zEitEr

New Member
#1
Hello,

Searching for syntax information on how to add rewrite rules using a OLS native format within a virtualHost. So I want to adapt:

Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^(xmlrpc\.php|wp-trackback\.php) - [F,L,NC]
    </IfModule>
Currently using this block:

Code:
  context /xmlrpc.php {
    accessControl {
      deny *
    }
  }

My very concern is about a need to restart OLS in case of using `context /xmlrpc.php` to get it working for a new WP installation. And I believe with rewrite rules we can avoid the need to restart OLS.

Another concern is about keeping error logs clear from messages like

Code:
[ERROR] [config:server:vhosts:vhost:example.net-443:context:/xmlrpc.php] Path for context location is invalid: /home/example/domains/example.net/public_html/xmlrpc.php
I guess I need to adjust the following block

Code:
  rewrite  {
    enable                  1
    autoLoadHtaccess        1
  }
within a virtualHost with my rules. But what syntax should I use. I don't find any example even here: https://www.litespeedtech.com/docs/webserver/config/rewrite

Regards,
Alex.
 

Cold-Egg

Administrator
#2

zEitEr

New Member
#3
Thank you for the links.

That turned out to be easier than I thought. Here the snippet that worked for me:

Code:
  rewrite  {
    enable                  1
    autoLoadHtaccess        1
    RewriteRule ^/(xmlrpc|wp-trackback)\.php - [F,L,NC]
  }
both with OpenLiteSpeed 1.4.48 and 1.5.2
 
Top