Redirect HTTP to HTTPS for WordPress on Linux

http-895558_1280.jpg

To redirect your WordPress website to the secure HTTPS protocol on Linux, then there are many steps that need to be taken before the redirect will work properly.

Steps For WordPress Preparation

Log in to WordPress

  1. Please select settings from the menu and click on General.

2. Locate the subsequent entries within the General settings

-WordPress Address (URL):

-Site Address (URL):

3. Update both URLS to incorporate HTTPS rather than HTTP

4. Save the changes

Steps For Linux Redirection

If the WordPress site is hosted on Linux, it will use an .htaccess configuration file. Placing the .htaccess within the root folder for your site will change the behavior of your site.

  • Download a replica of your .htaccess from your hosting account.
  • Open the file together with your favorite text editor
  • Make the required changes using the examples below.
  • Save your changes.
  • Kindly Upload the modified .htaccess to your hosting account.
  • Test your work by navigating normally to the online site, and it should redirect to HTTPS automatically.

Example WordPress .htaccess Content

Your WordPress site should have already got a default entry in your .htaccess file. it should look almost like this example:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

To ensure your hosting account will force the HTTPS protocol on all traffic to the location, you will need to feature the subsequent to the .htaccess file.

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

You can put the code snippet after the RewriteBase or within the .htaccess file. You can see the example:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Get the Web Design Write For Us Category in your blogging list because at Developer Gang we are accepting it.