htaccess if directive does not work

by Motivated   Last Updated August 14, 2019 10:01 AM - source

The following directive appears to fail in that it results in a 403 error.

<If "%{REQUEST_URI} =~ m#^(.*)?/uploads/(.*\.txt)#">
    Require all denied
</If>

The objective of the directive is to deny all requests and/or execution of text files in the directory "upload". The htaccess file is in the root of the web directory.

Based on the Apache documentation, if requests are processed last. If so, should the code be embedded towards the end of the htaccess file or can it be embedded anywhere.

Tags : htaccess


Related Questions


SEO executive .htaccess file knowledge

Updated September 05, 2017 07:01 AM


How to use .htaccess to block Russia

Updated February 20, 2018 00:01 AM

How to allow Options +Index in a .htaccess?

Updated June 14, 2018 15:01 PM

Redirect links using .htaccess file

Updated January 12, 2018 20:01 PM