8

I know that similar questions have been asked over and over, however after looking at them I have still not been able to get my server working properly.

I have an SSL certificate installed on my server.

When i hit https://www.ashleyclarke.me -> all is good

when i hit http://www.ashleyclarke.me -> redirects to https://www.ashleyclarke.me

when i hit http://ashleyclarke.me -> redirects to https://www.ashleyclarke.me

My problem is when I hit https://ashleyclarke.me, I have tried to set a redirect but with no luck.

<VirtualHost *:443>
    ServerAdmin me@ashleyclarke.me
    ServerName www.ashleyclarke.me
    ServerAlias ashleyclarke.me

    DocumentRoot /var/www/ashleyclarke.me/public

    <Directory /var/www/ashleyclarke.me/public>
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order deny,allow
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/ashleyclarke.me-error.log

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

    CustomLog ${APACHE_LOG_DIR}/ashleyclarke.me-access.log combined

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/ashleyclarke.me.crt
    SSLCertificateKeyFile /etc/apache2/ssl/ashleyclarke.me.key
    SSLCACertificateFile /etc/apache2/ssl/PositiveSSLCA2.crt

</VirtualHost>

<VirtualHost *:80>
    ServerAdmin me@ashleyclarke.me
    ServerName www.ashleyclarke.me
    ServerAlias ashleyclarke.me
    Redirect permanent / https://www.ashleyclarke.me
</VirtualHost>

Your advice is appreciated.

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
Ashley Clarke
  • 446
  • 1
  • 4
  • 12
  • I've encountered the same problem. Didn't find a satisfying solution, yet. Multiple VHosts could work, but our certificate only supports one domain and I bet it will stay that way... – zoku Dec 08 '16 at 09:06

1 Answers1

6

Just ran into a similar problem myself and found the answer here: https://stackoverflow.com/a/9945842/883960

SSL negotiation happens before the response from the server - so to actually do this you'll need an SSL certificate for ashleyclarke.me (without the www.) and setup a second :443 VirtualHost to just redirect.

Petecoop
  • 537
  • 5
  • 15