How do I redirect https:// to https://www

How can I redirect the https:// version to the version with www. in it? Thanks in advance!

Are you self-hosted and/or have access to your web server configuration?
For nginx add this section to /sites-available/yoursite.conf
You will need a SSL certificate (letsencrypt…) for both the and, I think they issue wildcard certs nowadays

server {
        listen 443;
        # $scheme will get the http protocol
        # and 301 is best practice for tablet, phone, desktop and seo
        return 301 $scheme://$request_uri;

You can also do this in javascript on the page if you can edit default.hbs - not elegant and more of a hack but it works, put this first thing after <body> tag

        if( == '')
            window.location.href="" + window.location.pathname;

If you use cloudflare, you can do this via a page rule without touching your server or website.

BTW, everyone removes www from their URLs nowadays. It is unnecessary and user has to press another 4 additional keystrokes for nothing.

Thanks for this! I did the hack but I have no idea where to add the section. I cannot find the sites-available map.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.