Redirect non-www https to www https on apache not working as expected
apache, redirect, ssl
Solution
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.
Problem
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.