Question

how to force TLS/SSL in the Wordpress one-click app

Ubuntu 18.04, no virtual server setup, single website only, following directions from marketplace, closed port 80, but there was no instructions on how to force all web traffic to use https.

Any help would be appreciated.

Thank you.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
March 13, 2020
Accepted Answer

Hi @johnnyrook,

I won’t recommend closing port 80 just redirecting all traffic from HTTP to HTTPS.

There are a few ways to do so.

  1. Redirect to https using .htaccess
  2. Redirect to https using a WordPress plugin
  3. Redirect to https via Nginx

Redirect to https using .htaccess

In your website’s .htaccess you can add the following code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

It should be enough to help you with the redirection.

Redirect to https using a WordPress plugin

Using a WordPress can be really easy, it will both help you redirect to HTTPS and solve the potential problem of a Mixed Content. Here are a couple of plugins you can use

https://wordpress.org/plugins/really-simple-ssl/

https://wordpress.org/plugins/wp-force-ssl/

Redirect to https via Nginx

If you are using Nginx, you can add the following server block

server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}

The above should be added in your website’s Nginx vhost file.

Additionally, please make sure to change example.com with your domain name.

Regards, KDSys

Bobby Iliev
Site Moderator
Site Moderator badge
March 13, 2020

This comment has been deleted

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Become a contributor for community

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    DigitalOcean Documentation

    Full documentation for every DigitalOcean product.

    Resources for startups and SMBs

    The Wave has everything you need to know about building a business, from raising funding to marketing your product.

    Get our newsletter

    Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

    New accounts only. By submitting your email you agree to our Privacy Policy

    The developer cloud

    Scale up as you grow — whether you're running one virtual machine or ten thousand.

    Get started for free

    Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

    *This promotional offer applies to new accounts only.