SSL

Redirect HTTP to HTTPS

Have you ever installed an SSL certificate and cannot see your site redirecting to HTTPS protocol? This time I’m going to show you how to redirect from HTTP to HTTPS for any application using the technologies I’ll describe below.

Table of contents

First of all, you need to know what is an SSL certificate, how to install it, is it easy or really hard, we have compiled different methodologies to create it, please review our blog about it here: Install SSL Certificate tutorial.

Now, what are the benefits of using a SSL Certificate?
  • Better positioning on Search Engines (Google, Bing, Yahoo)
  • Extended security for your application
  • Encrypted communication between client and server
  • Build Trust with customers
  • Safe Browsing
Types of Certificates
  • Extended Validation Certificates:
  • Organization Validated Certificates.
  • Domain Validated Certificates.
  • Single Domain Certificates.
  • Wildcard SSL Certificate.
  • Multi Domain SSL Certificate:
  • Unified Communications Certificate
There are different options to obtain a FREE SSL Certificate:
Cloudflare
ACME
Let’s Encrypt

If you want to learn more about how to install any of these, please take a look at this post.

How to Redirect traffic from HTTP:// to HTTPS://

Using Cloudflare:

1. Make sure Cloudflare is enabled for your site.

2. On the Crypto section, make sure to mark the right option.

If you need FULL, Flexible or FULL Strict setting. You can find more information about its use cases here.

3. Scroll down on the Crypto session and look for this option to be enabled:

Doing this you won’t have the need to add anything on your server configuration on Apache or Nginx. This is a great way to do it as Cloudflare gets in charge of the proxy settings!

Using Apache:

  1. # Ensure that Apache listens on port 80
  2. <VirtualHost *:80>
  3. DocumentRoot “/www/example1”
  4. ServerName www.example.com
  5. ServerAlias example.com
  6. # Other directives here
  7. #Redirect to 443/HTTPS Protocol
  8. RewriteEngine On
  9. RewriteCond %{HTTPS} !=on
  10. RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
  11. </VirtualHost>
  12. <VirtualHost *:443>
  13. DocumentRoot “/www/example1”
  14. ServerName www.example.com
  15. ServerAlias example.com
  16. # Other directives here
  17. </VirtualHost>

Using htaccess:

  1. RewriteEngine On
  2. RewriteCond %{HTTPS} !=on
  3. RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

Using Nginx:

  1. server {
  2. #===============================
  3. # Redirect Configuration
  4. #===============================
  5. listen 80;
  6. server_name example.com;
  7. return 301 https://example.com$request_uri;
  8. }
  9. server {
  10. #===============================
  11. # SSL Configuration
  12. #===============================
  13. listen 443;
  14. server_name example.com;
  15. }

Obtaining a SSL certificate is not an option now. Is a must if you want your site to
obtain the different benefits that a SSL provides. On this blog I showed you how to obtain a certificate with 3 different entities and how to redirect your traffic to the SSL.

Published by
Guillermo Velez

Recent Posts

The Best Python Libraries for AI Development

Why is Python frequently regarded as the top programming language for developing Artificial Intelligence? Based…

5 days ago

Benefits of Migrating to AWS Mexico Region

AWS launched a data center in Mexico. This new region, based in Querétaro with three…

2 weeks ago

Best Remote AI Companies to Work For In 2025

Most job seekers I talked to recently are searching for the best remote AI companies…

2 weeks ago

Best Data Analytics Tools by Industry: Top Picks for 2025

In 2025, organizations are making smarter business decisions that drive true revenue. And it’s all…

3 weeks ago

The Best 10 GenAI Tools for CTOs in 2025

GenAI tools are revolutionizing the tech landscape, enabling CTOs to enhance software development, security, observability,…

4 weeks ago

AWS Mexico Data Center Launch: A New Era for Cloud Growth

AWS has officially launched its new Data Center in Querétaro, Mexico​. This AWS Mexico data…

4 weeks ago