How To Redirect WordPress Blog to HTTPS

redirect-http-wordpress
Learn how to redirect WordPress blog to HTTPS

This article will help you move your WordPress blog from HTTP to HTTPS i.e. Secure HTTP.

These are different way to force HTTPS on whole or parts of WordPress blog.

You can also Enable HTTP Strict Transport Security to force WordPress Blog to HTTPS.

kinsta managed wordpress hosting
Pay Yearly, Get 2 Months FREE

Steps To Redirect WordPress Blog to HTTPS

  1. Login to your WordPress blog.
  2. Go to Settings.
  3. Select General.
  4. Change you WordPress Address (URL) and Site Address (URL) from HTTP to HTTPS.
  5. Force | Redirect through wp-config.php or .htaccess (Apache Server) or Nginx server.
  6. Update all your internal links from HTTP to HTTPS in database.
  7. Also update any CSS, Javascript or image links.

Redirect WordPress Blog to HTTPS through functions.php

Immediately stop the Bad Habit of putting custom code snippets in functions.php file.

Follow Good Habit and place the below code in WordPress Blog Specific Plugin.

convertkit email marketing tool
14 Days Free Trial

// Force (Redirect) WordPress Blog HTTP to HTTPS
function redirect_https () {
$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI'];
if ( !is_ssl() ) {
header( "Location: https://$host$uri", TRUE, 301 );
exit;
}
}
add_action ( 'template_redirect', 'redirect_https', 1 );

Redirect WordPress Blog to HTTPS through htaccess

# Force (Redirect) WordPress Blog HTTP to HTTPS
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

If above code does not work, try below code.

#Redirect WordPress Blog HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect WordPress to HTTPS through Nginx

Just add below code to force HTTP to HTTPS.

# Redirect WordPress Blog HTTP to HTTPS
server {
listen 80;
server_name yourblog.com www.yourblog.com;
return 301 https://$server_name$request_uri;
}

Live Chat Software
Improve Sales & Service with Chat & Ticketing System

Replace yourblog.com with your WordPress blog url.

To update all internal links, read How To Change WordPress Database Table Prefix with Full Confidence.

Then find and replace HTTP with HTTPS.

That’s it. All done.

WordPress Consultant

If you want to Redirect WordPress Site to HTTPS, contact me.