Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

http to https forwarding...

Posted on 2013-06-06
2
Medium Priority
?
259 Views
Last Modified: 2013-06-06
Hi, can someone let me know how I can forward requests to http://mydomain.com to https://mydomain.com? I am running a Apache2 on an ubuntu 12.04 Linux server. My current
sites-available/default file is as attached.

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName mydoamin.com:443
        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /usr/local/SSL/crt/mydomain.com.crt
        SSLCertificateKeyFile /usr/local/SSL/private/mydomain.com.key
        SSLCertificateChainFile /usr/local/SSL/crt/intermediate.crt
</VirtualHost>

Open in new window

0
Comment
Question by:aej1973
2 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 1600 total points
ID: 39227800
Add a new virtualhost that listens on port 80, and use mod_rewrite to perform the redirect.

Something like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName mydoamin.com
       
        RewriteEngine on
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
0
 

Author Comment

by:aej1973
ID: 39227948
Great, it work. Thank you.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses
Course of the Month9 days, 20 hours left to enroll

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question