How to move WordPress form HTTP to HTTPS

I have following code in my .htaccess file of a wp site

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I have done all the thing need for a WordPress site to operate in HTTPS now my site is opening in both the format i.e in HTTP and HTTPS, but if the user type example.com it goes to http not in https so to solve this I add few more code to solve this issue

Read More
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

but after adding this my site in not opening it says “ERR_TOO_MANY_REDIRECTS”

How to solve this issue, I want the user to go directly to https

Related posts

1 comment

  1. The problem is that you’re not checking if https is being used, so it just constantly tells the browser to go to https://www.yoursite.com/$1.

    You can use %{HTTPS} to check whether the request uses https.

    RewriteEngine on
    RewriteCond %{HTTPS} !^on$ [NC]
    RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]
    

Comments are closed.