BIOS,Windows, Linux, Software,Security, Domains, Web Hosting

Redirect HTTP to HTTPS in Apache

If you are using HTTPS in your website, you might need to redirect http to https for most users who visit your https pages by mistype as http. mod_rewrite in apache is very easy to use. This article I will list some methods to redirect http to https, use any of them as you prefer.

1. Modify httpd.conf

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect / https://www.example.com/
</VirtualHost >

2. Using mod_rewrite in .htaccess

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

3. Using location or meta

header(“Location:https://www.example.com”);

or,

<meta http-equiv="Refresh" content="0;URL=https://www.example.com" />

Related Articles

Comments(0)  

Leave a Reply

Subscribe to BootBeta Comments RSS feed to receive notification of latest comments posted.

Subscriptions

  • Enter Email Address:

Recent Post

Copyright@ 2010-2014 Bootbeta All Rights Reserved.
HooBlog Ver 1.5 Build 20140530