[Defender Pro] Allowing access to specific PHP files

Hi, I use defender to block access to PHP file. This creates the following in our htaccess file:

## WP Defender - Protect PHP Executed ##
<Files *.php>
Require all denied
</Files>
## WP Defender - End ##

However, there is a php file that resides in our plugins directory, as part of a custom plugin we created that needs to be accessed via the url in a browser. How would we allow access to this one file, keeping the rest of the Defender settings in tact?

For argument's sake lets say the file is in wp-content/plugins/custom-plugin/custom-file-to-allow.php

  • Ash
    • WordPress Hacker

    Hello Sanders Web Works

    Would you please try updating the rule to the following:

    ## WP Defender - Protect PHP Executed ##
    <Files *.php>
    Require all denied
    </Files>
    <Files /path/to/that/specific/php/file>
    Allow from all
    </Files>
    ## WP Defender - End ##

    Please make sure you set the correct path to /path/to/that/specific/php/file in the rule.

    Let us know how it goes. Have a nice day!

    Cheers,
    Ash

  • Sanders Web Works
    • Site Builder, Child of Zeus

    Thanks for the tip. We've done some more tweaking and eventually come up with the following (redir.php is the file that we needed to grant access to):

    We placed in the .htaccess file in *wp-content* folder and changed the content to:

    <FilesMatch "\.php$">
       Order Allow,Deny
       Deny from all
    </FilesMatch>
    <FilesMatch "redir[0-9]?\.php$">
       Order Allow,Deny
       Allow from all
    </FilesMatch>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.