Gertjan Klein wrote:
> Robert Ionescu wrote:
>
>> Gertjan Klein wrote:
>>> Is there a way to tell Apache to use (basic) athentication *only* when
>>> an HTTPS connection is made?
>> This should be spoosible, if you're placing the authentication
>> directives inside of a <directory /path/to/protect> within your
>> <virtualhost ...:443> section.
[...]
> However, I would prefer it if I could protect this particular directory
> from an .htaccess file.
The .htaccess file is read by each request, regardless if you're
requesting the site via the http or https protocol. But you can't define
a conditional statement like
"only https" -> require valid-user
This is not possible. Even if the require directive would support a
second argument "env=env-variable" like the allow/deny directive does,
the problem would be to set some ENV. This could be done with
mod_rewrite and a condition which checks for https, but authorization
comes before mod_rewrite acts in per-dir context (.htaccess files).
If you need the protection for some more virtualhosts, try to place it
into a separate file and include it in each <virtualhost ...>.
--
Robert
>> Stay informed about: Authentication when HTTPS