If you use .htaccess to control the file access, i guess u might came to a situation where you want to block all the files but except one. For an example, you might want to block all the php file access in WordPress wp-content folder using .htaccess. however some of the plugins need to have direct file access (and this is php file too). To solve this problem, you can use htaccess to allow the access for only one file.
To block all access except one file using .htaccess, follow the steps below:-
Advertisements
- Since we are using the WordPress example above, then we will provide the example for this example
- To block or deny all php file access, we have this content in the wp-content/.htaccess file:-
Order allow,deny Deny from all - Let say today we need to allow direct file access to wp-content/my-public-file.php, then we will add this at the bottom of the wp-content/.htaccess
Allow from all Satisfy any * for you to allow a specific plugin file, put the content above in a separate .htaccess in the plugin folder
- The final wp-content/.htaccess file content will look like this:-
# deny all php file access
Order allow,deny Deny from all # allow only one file accessAllow from all Satisfy any
Happy coding!
Related posts:
Linux - How to check memory usage
How to add calendar in Thunderbird - Lightning Calendar add-on
GMail: Too many simultaneous connections (Failure) in Thunderbird
How to hide .svn folders in Eclipse or Aptana
Prestashop 1.5 - How to enable add to cart button at Home Featured Product?
How to create mailing list in Thunderbird
How to disable keyboard vibration in Android
How to block .log file using in .htaccess
Share this with your friends:-