http://robsnotebook.com/xampp-ssl-encrypt-passwords 提供了一些关于如何使文件夹只能通过 SSL 加密访问的有用信息。它具体涵盖了这两个项目,这不是直接引用,而是要回答您的问题的本质摘录:
使文件夹只能通过 SSL 加密访问
首先,我们需要通知 Apache 您要加密的文件夹应该始终使用加密(并且永远不要明文加密)。这是通过在配置文件中每个所需的<Directory> 列表中放置一个 SSLRequireSSL 指令来完成的(可以将它放在最后,就在</Directory> 之前)。
Alias /web_folder_name "C:/xampp/foldername"
<Directory "C:/xampp/foldername">
...
...
SSLRequireSSL
</Directory>
将某些文件夹的“http”重定向到“https”
下一个可选步骤是将“http”请求重定向到我们想要保护的页面的“https”请求。这对用户更加友好,并允许您在输入地址时仍然使用 http(并自动切换到 https:// 和加密)。如果您不这样做,并且使用了 SSLRequireSSL,您将只能通过键入 https:// 来访问这些页面。这很好,可能更安全一点,但不是那么用户友好。为了完成重定向,我们将使用 mod_rewrite 以便我们不必在配置文件的这一部分中使用服务器名称。这有助于减少配置文件中写入服务器名称的位置(使您的配置文件更易于维护)。
首先,我们需要确保启用了 mod_rewrite。为此,请编辑 c:\xampp\apache\conf\httpd.conf 并删除此行中的注释(# 字符):
#LoadModule rewrite_module modules/mod_rewrite.so
让它看起来像这样:
LoadModule rewrite_module modules/mod_rewrite.so
现在,将以下文本粘贴到c:\xampp\apache\conf\extra\httpd-xampp.conf 的顶部:
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect /xampp folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} xampp
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /phpMyAdmin folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} phpmyadmin
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /security folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} security
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /webalizer folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} webalizer
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
</IfModule>
如果您想要重定向到 https:// 的其他文件夹,请在下面添加通用文本(但替换您的文件夹名称):
# Redirect /folder_name folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} folder_name
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]