<Location> and <FileMatch> Rewrite Rules

Rewrite rules located inside <Location> or <FileMatch> tags are not supported by LiteSpeed Web Server.

Let's say you want to block a URL /rejectthisurl for all virtual hosts on a cPanel server. To achieve this, you add an include file for all cPanel virtual hosts at /etc/apache2/conf.d/userdata/rejectthisurl.conf, and use a <Location> directive, like so:

<Location /rejectthisurl>
RewriteEngine on
RewriteRule .* - [F]
</Location>

This works for Apache (returning 403 as expected), but not for LSWS (returning 404 instead of 403).

Since LSWS doesn't support rewrite rules inside of <Location> or <FileMatch>, you need another way.

Simply use an appropriate rewrite rule to achieve the same goal. For the above example, you can add the following to /etc/apache2/conf.d/userdata/rejectthisurl.conf:

RewriteRule ^/rejectthisurl - [F]