I have used code like this in apache configuration to protect locations with password
<Location ~ "/admin.*">
AuthType Basic
AuthName "Protected Area"
AuthUserFile /home/user/public_html/.htpasswd
Require valid-user
</Location>
is there a way to do the same thing using an htaccess file?
the locations I want to protect don't really exist on the filesystem, it's locations available thanks to mod_rewrite
Yep, with
<Files>
(or<FilesMatch>
): http://httpd.apache.org/docs/2.2/mod/core.html#filesEdit: "Note that unlike Directory and Location sections, Files sections can be used inside .htaccess files. This allows users to control access to their own files, at a file-by-file level."
Yes it's possible to do so put a htaccess in the file you want to moderate the access. Put the same text as in the configuration file. Make sure that your conf files will read .htaccess.