I have this rule in my root .htaccess file:
# DENY ACCESS TO EVERYTHING INSIDE PHP DIRECTORY
RewriteCond %{HTTP_REFERER} !^http://(www\.)?someurl [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?someurl.*$ [NC]
RewriteRule ^php - [F]
It denies access to all files inside the "php" directory if accessed outside my server.
How to add one specific file exception, let's call that file "_sharer-socnets.php" using above logic of RewriteCond
/ RewriteRule
?
To deny all but one file you can use this rule:
# DENY ACCESS TO EVERYTHING INSIDE PHP DIRECTORY
RewriteCond %{HTTP_REFERER} !^http://(www\.)?someurl [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?someurl.*$ [NC]
RewriteCond %{REQUEST_URI} !/_sharer-socnets\.php$ [NC]
RewriteRule ^php - [F,NC]