.htaccess, mod_rewrite, and basic authentication example. You won’t need mod_rewrite for this, hopefully, this should do the trick:
SetEnvIfNoCase Request_URI ^/some/path/to/protect require_auth=true
SetEnvIfNoCase Request_URI ^/another/protected/path require_auth=true
# Auth stuff
AuthName "Password Protected"
# Setup a deny/allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
# 1. a valid authenticated user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.