redirection from non-www to www through HTTPS takes longer than HTTP

redirection from non-www to www through HTTPS takes longer than HTTP - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the redirection from non-www to www through HTTPS takes longer than HTTP error on your web browser. Problem :


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):




Solution :

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.


We hope that this article has helped you resolve the redirects, apache, https error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=