1

Currently my website URL, for quickest access to the site, it is of the form https://www.example.co.uk.

Generally, if people know of your website, they will enter example.co.uk.

Entering the website this way, causes the browser to do 2 redirects. First to https://example.co.uk and then to https://www.example.co.uk.

This adds in the region of an extra 1.5 - 2 seconds load time.

Ideally, I would like 1 redirect, from example.co.uk straight to https://www.example.co.uk.

I have tried the redirection plugin but that does not seem to do anything for this sort of problem and I have a feeling that it lies within .htaccess.

Has anyone else encountered this? Is there any proven method of minimizing the effects of redirects and reducing it to one redirect and minimizing the time the redirect takes?

1 Answer 1

0

This adds in the region of an extra 1.5 - 2 seconds load time.

These redirects alone should not be adding "an extra 1.5 - 2 seconds load time". If it is then you would seem to have other problems with your server response time or slow network speeds.

After the initial request, any DNS lookups are cached by the browser/system and once the redirect(s) have been experienced the first time, the redirects themselves are cached by the browser (or should be if you have implemented 301 permanent redirects).

Ideally, I would like 1 redirect, from example.co.uk straight to https://www.example.co.uk.

Yes, this has always been the preferred method in the past (to minimise the additional redirects). However, these days, it is often recommended to redirect from HTTP to HTTPS on the same host first and then canonicalise the hostname (ie. non-www to www redirect) in a second request (if required). And you will need to do this two-stage redirect if you plan on implementing HSTS, which is certainly recommended if you are committed to HTTPS and security.

So, arguably, you are already doing it the recommended way.

However, it's relatively straight forward to do this in a single redirect if you wish. For example (depending on your config), something like:

RewriteEngine On
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.example.co.uk/$1 [R=301,L]

The above states... for all requests that are not HTTPS or where the requested Host header does not start www. then redirect to https://www.example.co.uk/<URL-path>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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