This is an old revision of the document!

Rewrite rules inside <Location> or <FileMatch> are not supported by LSWS

You may want to block a URL /rejectthisurl for all virtual hosts on cpanel server. To achieve this, you added a include files for all cPanel virtual hosts at /etc/apache2/conf.d/userdata/rejectthisurl.conf by using a <Location> directive:

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

It works for Apache (returning 403 as expected) but not for LSWS (returning 404 instead of 403). Why? Actually, LSWS doesn't support rewrite rules inside <Location> or <FileMatch> context, but you can easily just use appropriate rewrite rules to achieve the same goal. For the above example, you can use the following instead in /etc/apache2/conf.d/userdata/rejectthisurl.conf

RewriteRule ^/rejectthisurl - [F]
  • Admin
  • Last modified: 2018/12/21 15:19
  • by Jackson Zhang