Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Web Servers»Apache»Apache Redirect HTTP to HTTPS

    Apache Redirect HTTP to HTTPS

    RahulBy RahulOctober 13, 20151 Min ReadUpdated:June 30, 2020

    Force Redirect HTTP to HTTPS in Apache – Many of sites required to always running with SSL only. And we need to ensure that every user must access the website through SSL. If any user tried to access the website with non-ssl URL, He must be a redirect to SSL website. This tutorial will help you to redirect website to SSL URL each time using Apache mod_rewrite module.

    Option 1 – Redirect HTTP to HTTPS

    Edit website VirtualHost in Apache configuration file and add the following options. Change www.example.com with your actual domain name.

    Redirect permanent / https://www.example.com/
    

    Option 2 – Redirect HTTP to HTTPS

    Edit website VirtualHost in Apache configuration file and add the following settings. You may also add the same settings in .htaccess file under document root of your website.

      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    

    If you want to redirect specific URL to https. Use following settings. For example, if anyone tried to access the always-secure.html file on the website. The user must have to access URL with SSL.

      RewriteEngine On
      RewriteRule ^always-secure.html$ https://www.example.com/always-secure.html [R=301,L]
    
    Apache http https Openssl SSL
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Backup and Restore SVN Repository in Linux
    Next Article Web Design Trends that are Here to Stay

    Related Posts

    How to Install Apache ActiveMQ on Ubuntu 22.04

    3 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How To Disable HTTP Methods in Apache

    Updated:December 31, 20212 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    Common Apache Commands on Ubuntu & Debian

    4 Mins Read

    How to Install and Secure Apache on Debian11

    6 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.