XCEPTION
XCEPTION

Reputation: 1753

Wordpress http to https redirection

I have a wordpress website with ssl implemented. The website is working properly at https://domain.com. I want to redirect all the traffic from http://domain.com to https://domain.com. I googled about this and changed my .htaccess to following:

<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>

The redirection is not working. I have tried plugins like Easy HTTPS redirection, Wordpress HTTPS, etc but still it is not working. Can someone please help me out on this. Also i would like to add that when I try to visit http://domain.com it does not connect. Thanks in advance.

Upvotes: 0

Views: 1786

Answers (5)

Michiganman
Michiganman

Reputation: 11

Make sure that you define the WP_SITEURL and WP_HOME at wp-config.php

define('WP_HOME','https://yourdomain.com');
define('WP_SITEURL','https://yourdomain.com');

And add this condition to check if the https at wp-config.php

 if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
    $_SERVER['HTTPS'] = 'on';
}

Upvotes: 1

user10336471
user10336471

Reputation: 1

Try moving the RewriteBase below the http redirect and into the wordpress section. It solved my the issue for me.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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

Upvotes: 0

Margach Chris
Margach Chris

Reputation: 1729

Make sure you have changed the settings in wp_options table, siteurl and home to include

option_name                     option_value     
siteurl                         https://<your domain>
home                            https://<your domain>

Upvotes: 1

Jordi Nebot
Jordi Nebot

Reputation: 3401

You shoudn't need a plugin to do this...

Try with this little change in your .htaccess's RewriteRule:

RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Upvotes: 1

Alex Belov
Alex Belov

Reputation: 61

To redirect all the traffic from http://.com to https://.com i use this plugin ( works always for me): https://wordpress.org/plugins/wp-force-ssl/

Upvotes: 0

Related Questions