THE IT IDEAS

  • Home

Wednesday, 3 December 2014

How to redirect HTTP to HTTPS

 THE IT IDEAS     11:50     apache2   

First you need to install SSL Certificate Successfully. Once your done that choose any of example to do redirect url.

Example : 1

In this example you don't need mod rewrite module to be enabled.

Open your apache configuration file 

#nano /etc/apache2/sites-enabled/000-default.conf

Modify your VirtualHost Tag as followed 

<VirtualHost *:80>
    ServerName www.example.com (your domain name)
    Redirect / https://www.example.com/
</VirtualHost>

Save and exit. Restart apache service once
#service apache2 restart

Check your domain url with http it will redirect automatically on HTTPS.


Example : 2

In this Example you have to enable mod rewrite module first with below command

#a2enmod rewrite

Now, Copy below code in your .htaccess file without any changes on beginning of .htaccess file.


# BEGIN REWRITE SITEWIDE HTTP TO HTTPS

# This will enable the Rewrite capabilities
RewriteEngine On

# This checks to make sure the connection is not already HTTPS
RewriteCond %{HTTPS} !=on

# This rule will redirect users from their original location, to the same location but using HTTPS.
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

# END REWRITE SITEWIDE HTTP TO HTTPS

Save and exit from file.

Now open your apache configuration file and make mentioned changes in your file.

1) "AccessFileName .htaccess" tag should be open.

2) Check Directory tag and change "AllowOverride None" to "AllowOverride All"

e.g.

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Save and exit the file.

Restart Apache service once

#service apache2 restart


All Done Check now !!!




  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

Like Us !!!

Recent Posts

Blog Archive

  • ►  2016 (1)
    • ►  April (1)
  • ►  2015 (12)
    • ►  August (1)
    • ►  May (2)
    • ►  April (8)
    • ►  March (1)
  • ▼  2014 (23)
    • ▼  December (8)
      • How to resolve mcrypt extension missing error.
      • How to upload EC2 Data to S3 Bucket with s3cmd
      • How to move github local folder to another location.
      • Basic GitHub Commands
      • Installation and configuration of GeoIP module in php
      • Install MongoDB php driver in XAMPP/LAMPP
      • How to redirect HTTP to HTTPS
      • How to Create VirtualHost in Apache 2.4
    • ►  November (12)
    • ►  April (2)
    • ►  March (1)
  • ►  2013 (7)
    • ►  December (1)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (3)
  • ►  2012 (15)
    • ►  December (6)
    • ►  November (9)

Categories

apache2 EC2 error mysql php ubuntu aws aws rds browser github installation linux mount s3 AWS Bucket CentOS Computer DocumentRoot change How to Benchmarking Webserver IP LAMP Restart Computer SCP command SQL SERVER XRDP administrator amazon rds backup basic commands chat command line disable download drupal ec2.chroot environment external storage device fstab functions geoip gmail google home page iis instance internet java mod rewrite mongodb multiple login network password one password php5 php5-fpm php7 private browsing python repair filesystem repo reset password rhel sa password same computer script sftp share skype ssh tomcat ubuntu 16.04 ubuntu16 visudo windows 8 youtube
JobsMagBlogJobsMag.InThingsGuide

Popular Posts

  • Install MongoDB php driver in XAMPP/LAMPP
    To install the php driver for MongoDB Prerequisite :: #sudo apt-get install autoconf #export PHP_AUTOCONF=/usr/bin/autoconf #sudo apt...
  • How to Install PHP 7.0, Apache 2.4.18, & MySQL 5.7 on Ubuntu 16.04 LTS
    Update your repo list with below command $ sudo apt-get update -- > Install Apache 2.4.18 $ sudo apt-get install apac...
  • Share Internet from one PC to another PC
    Open Network Connections by clicking the Start button , clicking Control Panel , clicking Network and Internet , clicking Network and S...

Copyright © THE IT IDEAS | Powered by Blogger