Differences
This shows you the differences between two versions of the page.
litespeed_wiki:config:rewrite-inside-location-not-supported [2018/12/21 15:19] Jackson Zhang created |
litespeed_wiki:config:rewrite-inside-location-not-supported [2018/12/21 15:36] (current) Lisa Clarke Copyediting |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Rewrite rules inside <Location> or <FileMatch> are not supported by LSWS ====== | + | ====== <Location> and <FileMatch> Rewrite Rules ====== |
+ | Rewrite rules located inside ''<Location>'' or ''<FileMatch>'' tags are not supported by LiteSpeed Web Server. | ||
- | 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: | + | 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> | <Location /rejectthisurl> | ||
Line 8: | Line 9: | ||
</Location> | </Location> | ||
- | 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'' | + | 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] | RewriteRule ^/rejectthisurl - [F] | ||
+ |