Search code examples
apache.htaccessmod-rewrite

.htacess specifying specific files on one line


I have the following in part of my .htaccess file:

# the following prevents display of the filetohide file
<files handler.php>
order allow,deny
deny from all
</files>

<files submit.php>
order allow,deny
deny from all
</files>

Can multiple file specifiers not be done within a single set of tags, i.e:

<files submit.php|handler.php|otherfile.txt>
order allow,deny
deny from all
</files>

Solution

  • Could you please try following, if this helps you for multiple file names with different formats(I am yet to test this but written this based on regex).

    <files ~ "^((submit|handler)\.php)$|^(otherfile\.txt)$">
    order allow,deny
    deny from all
    </files>