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:-
1234<FILES ~ "\.php$">Order allow,denyDeny from all</FILES> - 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
1234<Files my-public-file.php>Allow from allSatisfy any</Files>
* 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:-
1234567891011# deny all php file access<FILES ~ "\.php$">Order allow,denyDeny from all</FILES># allow only one file access<Files my-public-file.php>Allow from allSatisfy any</Files>
Happy coding!
Related posts:
Secure file transfer thru scp in Mac and Linux
Linux: How to mount iso image file
WordPress: add javascript event after widget save
How to setup SSH without password
How to create bootable Linux USB drive - UNetbootin
Fckeditor - File Manager Session Problem in IE7
How to forward email as inline in Thunderbird
Free FTP Client for Mac OS X / Win XP / Vista
Share this with your friends:-