HTTP automatic jump to HTTPS tutorial after installing SSL certificate

Source: Internet
Author: User
Tags ssl certificate godaddy ssl certificate

When we visit other sites, we may see the difference between HTTP and HTTPS in front of the URL. What is the reason for that? Originally, the URL before the https//prefix is because of the use of SSL encryption, so the advantage of the encryption is that users visit the site when the computer and the server to send and receive information between the transmission will be more secure. We install the GoDaddy SSL certificate can achieve this effect.

Of course, after the installation certificate is completed, to achieve the input domain name automatically jump to HTTPS, we also need to add code to achieve the effect. GoDaddy host has Linux and Windows, so the different operating system settings are not the same.

Linux Host

If you are using a Linux host, you need to add the following code in the root directory of your Web site (no need to create one) and save it:

Rewriteengine on

Rewritecond%{server_port} 80

Rewriterule ^ (. *) $ https://www.yourdomainname.com/$1 [r,l]

(The domain name of your site replaces the yourdomainname.com above)

Of course, if you want to specify that a file uses HTTPS, add the code (at which point the. htaccess file needs to be placed in the folder you specify):

Rewriteengine on

Rewritecond%{server_port} 80

Rewritecond%{request_uri} SomeFolder

Rewriterule ^ (. *) $ https://www.yourdomainname.com/somefolder/$1 [r,l]
(The domain name of your site replaces the yourdomainname.com above)

Windows host

GoDaddy's Windows host needs to be in the Web.config file (no need to create), and then add the following code inside the file:

<rule name= "HTTP to HTTPS redirect" stopprocessing= "true" >

<match url= "(. *)"/>

<conditions>

<add input= "{HTTPS}" pattern= "Off" ignorecase= "true"/>

</conditions>

<action type= "Redirect" redirecttype= "Found" Url= "https://{http_host}/{r:1}"/>

</rule>

The above method enables HTTP to automatically jump to 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.