Skip to main content

How to Setup WordPress to Use SSL and HTTPS

f you are starting a new site and/or want to use HTTPS everywhere on your site, then you need to update your site URL.

  • You can do this by going to Settings -> General and updating your WordPress Address (URL) and Site Address (URL) address fields.
    Now if you’re adding SSL to your existing site, then you need to setup WordPress SSL redirect from HTTP to HTTPS.
  • You can do this by adding the following code in your .htaccess file:
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]

Don’t forget to replace yoursite.com with your site URL.

Open your wp-config.php and find the “That’s all, stop editing! Happy blogging.” row, and place above this code:

define('FORCE_SSL_ADMIN', true);
// in some setups HTTP_X_FORWARDED_PROTO might contain 
// a comma-separated list e.g. http,https
// so check for https existence
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
       $_SERVER['HTTPS']='on';