Report this

What is the reason for this report?

Redirect http request -> https

Posted on April 25, 2013

Hi!! I activated 5$ plan vps yesterday, I’m quite impressed. I’m developing a management application, that have to run throught ssl. I created this virtualhost (following the guide on digital ocean): <VirtualHost *:443> ServerAdmin maltesepiero@gmail.com ServerName emmepiesse.no-ip.org:443 ServerAlias www.emmepiesse.no-ip.org:443

    DirectoryIndex index.html
    DocumentRoot /var/www/mps

    # CGI Directory
    ScriptAlias /cgi-bin/ /var/www/mps/cgi-bin/
    <Location /cgi-bin>
            Options +ExecCGI
    </Location>
  SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

</VirtualHost>

and it works well, but I’ll have issue in redirecting http traffic. I tried with: <VirtualHost *:80> ServerName emmepiesse.no-ip.org Redirect / https://emmepiesse.no-ip.org:443 </VirtualHost> but no luck. Ideas? Thank you in advance



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The issue with the redirect is that you won’t be able to preserve for the REQUEST_URI so if a user goes to http://emmepiesse.no-ip.org/blog they will end up on https://emmepiesse.no-ip.org - as for why the redirect isn’t working you may want to update it to: <br> <br>Redirect permanent / https://emmepiesse.no-ip.org:443 <br> <br>Alternatively you can use .htaccess + mod_rewrite to setup a rewrite rule as follows which would redirect requests and also preserve the requested path/document: <br> <br>RewriteEngine On <br>RewriteCond %{HTTPS} off <br>RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} <br> <br>You can also replace HTTP_HOST with SERVER_HOST, HTTP_HOST refers to what the user provided in his URL when using his browser, while the SERVER_HOST refers to the Server Name that was defined in the config file for which the domain/IP matched in your configuration.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.