Unable to redirect http to https on Apache2 server

yo_bee
yo_bee used Ask the Experts™
on
How to redirect all http traffic to https on Ubuntu running Apache2.
Here is my sites conf file and I am not able to drive the traffic to https.

<VIRTUALHOST *:80>
        ServerName OldDomian.com
        ServerAlias www.OldDomian.com
        Redirect /  https://www.NewDomain.com
       	ServerName NewDomain.com
        ServerAlias www.NewDomain.com
        Redirect /secure https://www.NewDomain.com

	
</VIRTUALHOST>
<VIRTUALHOST *:443>
    ServerAdmin webmaster@localhost
    ServerName www.NewDomain.com
    ServerAlias NewDomain.com
    DocumentRoot /var/www/www.NewDomain.com/web
    SSLEngine on    
    SSLCertificateFile /etc/apache2/cert/359dc02304e01eae.crt    
    SSLCertificateKeyFile /etc/apache2/cert/hp.key
    #SSLCertificateFile /etc/apache2/cert/gd_bundle-g2-g1.crt
    <DIRECTORY />
        Options FollowSymLinks
        AllowOverride All
    </DIRECTORY>
    <DIRECTORY /var/www/www.NewDomain.com/web>
        Options +FollowSymLinks
        AllowOverride All
        #AuthType Basic
        #AuthName "Restricted Content"
        #AuthUserFile /etc/apache2/.htpasswd
        #Require valid-user

        # <IfModule mod_rewrite.c>
        # RewriteEngine On
        # RewriteBase /
        # RewriteCond %{REQUEST_FILENAME} -f [OR]
        # RewriteCond %{REQUEST_FILENAME} -d
        # RewriteRule ^.*$ - [S=40]
        # RewriteRule (.*)/(.*)/$ /index.php?page=$1&id=$2 [QSA,L]
        # RewriteRule (.*)/$ /index.php?page=$1 [QSA,L]
        # </IfModule>
        # php_value auto_prepend_file /var/www/www.NewDomain.com/prepend.php
    </DIRECTORY>
    ErrorLog ${APACHE_LOG_DIR}/www.NewDomain.com_error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/www.NewDomain.com_access.log combined
</VIRTUALHOST>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Principal Software Engineer
Commented:
Suggest having a look at the solution in the previous EE discussion linked below:

https://www.experts-exchange.com/questions/29002206/Apache-Rewrite-HTTP-To-HTTPS.html
yo_beeDirector of Information Technology

Author

Commented:
Thanks for you help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial