Some common ways to force a server to jump HTTPS

Source: Internet
Author: User

IIS version
Introduction to Implementing HTTP Auto-Convert to HTTPS methods in IIS
1. Back up the following files according to the IIS version:
IIS6.0 Path: C:\WINDOWS\Help\iisHelp\common\403-4.htm
IIS7.0 above path: C:\inetpub\custerr\zh-CN\403.htm
2. Replace all the contents of the following (403-4 or 403) and save
<HTML><HEAD><TITLE> This page must be viewed through the secure channel </TITLE>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
</HEAD><BODY>
<script type= "Text/javascript" >
var url = window.location.href;
if (Url.indexof ("https") < 0) {
url = url.replace ("http:", "https:");
Window.location.replace (URL);
}
</script>
</BODY></HTML>
Note: In IIS6, Site Properties-"Directory Security-" edit the "Require secure channel (SSL)" tick.
IIS7, 8, SSL Settings-"Require SSL" check.

APache version
If you need an entire station jump, type the following in the <Directory> tab of the Web site's configuration file:
Rewriteengine on
Rewritecond%{server_port}!^443$
Rewriterule ^ (. *)? $ https://%{server_name}/$1 [L,r]
Copy Code
If you are making an HTTPS push jump to a directory, copy the following code:
Rewriteengine on
Rewritebase/yourfolder
Rewritecond%{server_port}!^443$
#RewriteRule ^ (. *)? $ https://%{server_name}/$1 [L,r]
Rewriterule ^.*$ Https://%{server_name}%{request_uri} [L,r]
If you only need to make an HTTPS jump on a webpage, you can use redirect 301来 to jump! REDIRECT 301/Your page https://your host + page

Tomcat version
Need to make two local changes.
1:server.xml the port to configure the SSL certificate to change to the default "443" port, if it has been modified, please direct operation of the second step;
2: Add the node code in the Web. XML configuration file:
<web-app>
.........
<security-constraint>
<web-resource-collection >
<web-resource-name >SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
</web-app>
3: Back to the Server.xml configuration file found in the 80-port node, which has the default property is Redirectport= "8443" to Change to "443" to save the restart.

Nginx version
In the configuration of port 80 files, write the following content.
server {
Listen 80;
server_name localhost;
Rewrite ^ (. *) $ https://$host $ permanent;
Location/{
root HTML;
Index index.html index.htm;
}
Separate page common code snippet:
Include this code on pages that require mandatory HTTPS for processing
<script type= "Text/javascript" >
var url = window.location.href;
if (Url.indexof ("https") < 0) {
url = url.replace ("http:", "https:");
Window.location.replace (URL);
}
</script>
Copy Code

More detailed reference SSL certificate: www.evtrust.com

Some common ways to force a server to jump HTTPS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.