如何只在指定的XAMPP目录启用SSL [英] How to enable SSL only on specified XAMPP directories

查看:262
本文介绍了如何只在指定的XAMPP目录启用SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够使用makecert做一个自签名的证书目前允许HTTPS上的所有目录中的C:// XAMPP / htdocs中

I've been able to use makecert to make a self signed cert which currently enables HTTPS on all directories in C://XAMPP/htdocs

我有我想不同的两个目录,

I have two directories which I want to be different,

c:/XAMPP/htdocs/PLACEHOLDER1 
c:/XAMPP/htdocs/PLACEHOLDER2

我在想,如果我希望能够有SSL范围仅限于一个目录,说在这种情况下,PLACEHOLDER1。

I was wondering if it'd be possible have the SSL scope limited to one directory, say in this case 'placeholder1'.

这是使用SSL很抱歉任何混乱。我第一次

It's my first time using SSL so sorry for any confusions.

推荐答案

的http:// robsnotebook。 COM / XAMPP-SSL-加密,密码对如何使文件夹仅SSL加密访问一些有用的信息。它具体包括这两个项目,这不是一个直接的报价,但精华摘录回答你的问题:

http://robsnotebook.com/xampp-ssl-encrypt-passwords has some good information on how to make folders accessible by SSL encryption only. It specifically covers these two items, this is not a direct quote, but is an excerpt of the essence to answer your question:

使文件夹使用SSL加密只能访问的结果
首先,我们需要告知Apache的,你要加密应该使用总是使用加密(和明确永远不会)的文件夹。这是通过把一个SSLRequireSSL指令在配置文件中每个需要的房源内完成(这是确定把它在年底之前正好)。

Make folders accessible with SSL encryption only
First, we need to inform Apache that the folders you want to encrypt should use always use encryption (and never go in the clear). This is accomplished by putting an SSLRequireSSL directive inside of each desired listing in the config files (it is ok to put it at the end, just before the ).

Alias /web_folder_name "C:/xampp/foldername"
<Directory "C:/xampp/foldername">
    ...
    ...
    SSLRequireSSL
</Directory>

重定向HTTP为https对于特定文件的结果
下一个可选步骤是重定向HTTP请求我们要保护的页面为https的请求。这是更加人性化,并允许您仍然使用HTTP当你在地址类型(并自动切换到https://开头和加密)。如果你不这样做,你使用SSLRequireSSL,你将只能通过键入HTTPS访问这些页面://。这是罚款和可能有点更安全,但也不是那么人性化。为了实现重定向​​,我们将使用mod_rewrite使我们不必在配置文件中的这部分使用的服务器名称。这有助于保持小的名额在服务器名称写在配置文件(让你的配置文件更容易维护)。

Redirect "http" to "https" for certain folders
This next optional step is to redirect "http" requests to "https" requests for the pages we want to secure. This is more user friendly and allows you to still use http when you type in the address (and automatically switch to https:// and encryption). If you don’t do this, and you used SSLRequireSSL, you will only be able to access these pages by typing https://. This is fine and probably a little bit more secure, but is not so user friendly. To accomplish the redirection, we will use mod_rewrite so that we don’t have to use the server name in this part of the config file. This helps keep small the number of places in the config files where the server name is written (making your config files more maintainable).

首先,我们需要确认mod_rewrite已启用。要做到这一点,编辑c:\\ XAMPP \\ apache的\\的conf \\ httpd.conf文件,并在该行摆脱评论(#字符)的:

First, we need to make sure that mod_rewrite is enabled. To do this, edit c:\xampp\apache\conf\httpd.conf and get rid of the comment (# character) in this line:

的LoadModule rewrite_module模块/ mod_rewrite.so 的结果
使它看起来是这样的:

LoadModule rewrite_module modules/mod_rewrite.so
to make it look like this:

的LoadModule rewrite_module模块/ mod_rewrite.so
现在,将以下文本粘贴到C的顶部:\\ XAMPP \\ apache的\\的conf \\额外\\的httpd-xampp.conf:

LoadModule rewrite_module modules/mod_rewrite.so Now, paste the following text into the top of c:\xampp\apache\conf\extra\httpd-xampp.conf:


    RewriteEngine叙述在

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]


如果你要重定向到https其他文件夹://,添加下面的通用文本(但替换您的文件夹名称):

If you have other folders you want to redirect to https://, add the generic text below (but substitute your folder name):

# Redirect /folder_name folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} folder_name
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]

这篇关于如何只在指定的XAMPP目录启用SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆