Prashant Saxena
Prashant Saxena

Reputation: 35

HTTPS Loop redirection

Anyone help me to stop redirection in HTTP to https in WordPress site.

Here is scenario

http://example.com 301 Moved Permanently https://example.com/ 301 Moved Permanently https://www.example.com/ 200 OK

Upvotes: 1

Views: 74

Answers (1)

Haris
Haris

Reputation: 545

So if I understand correctly, this is your .htaccess file:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
RewriteBase / 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>

Aod you want to redirect page from http://example.com and https://example.com - both to https://www.example.com - is this correct?

If so, use this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] 

What this does, it redirects the page from non-www to www and then it forces https.

Upvotes: 2

Related Questions