0

I have enabled SSL for my site in the vhost file. I also have the redirection for the non-www to www over port 80:

<VirtualHost 62.210.85.6:80>
 ServerName pretty-story.com
 Redirect permanent / https://www.pretty-story.com/
</VirtualHost>

However it seems it takes a lot longer (about 2 seconds) to redirect from non-www to www over https.

So if I type http://pretty-story.com, it quickly resolves to https://www.pretty-story.com but if I type https://pretty-story.com it takes more than 2 seconds to resolve to https://www.pretty-story.com !

I tried to add the following :

<VirtualHost 62.210.85.6:443>
  ServerName pretty-story.com
  Redirect permanent / https://www.pretty-story.com/
</VirtualHost>

But then the website becomes inaccessible.

What should I do ?

Here's the results on pingdom (using Sweden because my CDN is only active in Europe):

4
  • Highly recommend that you use multiple servers rather than just one server in Sweden. Use: webpagetest.org with multiple passes and multiple locations. Jan 16 '17 at 10:54
  • Sure, but pagespeedinsight gives me the same result. It tells me to improve server response time whenever I test with the url pretty-story.com
    – Sam
    Jan 16 '17 at 11:41
  • found the answer in this post : askubuntu.com/questions/653923/… I needed to add SSL settings to HTTPS vhost redirection too
    – Sam
    Jan 18 '17 at 19:41
  • Sam, if you found a suitable answer you can quoteblock the source as an answer yourself. Jan 19 '17 at 17:49
0

The answer to this question is detailed here : https://askubuntu.com/questions/653923/force-https-and-www-with-virtual-host-apache2/653947#653947

The key thing was to have 3 VirtualHost :

  • one for the http to https redirection
  • one for the https non-www to www redirection, which includes all the SSL settings
  • one for the https www version, which contains all the SSL settings + anything else you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.