Jeeten Parmar
Jeeten Parmar

Reputation: 5787

Redirect from http to https using .htaccess

I want to redirect my wordpress website from http to https so I am using below code in .htaccess. But it is giving me error 'The page isn’t redirecting properly'.

RewriteCond %{HTTPS} off
RewriteRule ^ https://www.mywebsite.com%{REQUEST_URI} [L,NE,R=301]

I already enabled SSL in wp-config file and it is working fine if I go from one page to another page. I am getting issue only when I copy paste any http link in browser then it is not redirecting to https.

Upvotes: 0

Views: 75

Answers (2)

Ravi Patel
Ravi Patel

Reputation: 5231

Redirect Http to https:

  # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

Upvotes: 0

lky
lky

Reputation: 1129

I use the following, also ensure that you have no caching plugins that may be enabled.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]]
</IfModule>

Upvotes: 1

Related Questions