Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many Redirects after switching WordPress to https

with my WordPress-Blog, I switch to https. Therefore, I have add the following code to my .htaccess-File. My Problem now is, that I get the issue "Too many Redirects". Thank you for your tips!

Domain is a Subdomain:

https://en.example.com

# Begin Force SSL
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
# End Force SSL
# 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
like image 555
mm1975 Avatar asked Apr 06 '15 20:04

mm1975


People also ask

How do I force WordPress to redirect to https?

Log into your WordPress dashboard ang go to Settings > General. Scroll down to the WordPress and Site URL Address field and replace the HTTP with HTTPS.

Does WordPress automatically redirect https?

Note: If your site is hosted on our Managed WordPress hosting platform you do not need to manually change these settings, the HTTPS protocol will be configured automatically.


1 Answers

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';
    }
like image 143
abdallah Nofal Avatar answered Nov 15 '22 23:11

abdallah Nofal