-1

I have an linux package via 123-reg, hosting a standard Wordpress site. I have an SSL certificate installed and setup.

To get Wordpress working on HTTPS, i updated the site and home URL via wp-config, as I normally do, however this wasn't working and causing infinite redirect loops. No idea why.

So I added $_SERVER['HTTPS']='on'; in wp-config (found a suggested post), and it then loaded fine on https. No idea why this works?

I then wanted to force redirect http to https, so in htaccess i added:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

This does force it to https, but then a infinite redirect loop occurs, redirecting to itself!

I've done a search and replace on the database to replace any mentions of http to https.

Any advice please? Thank you.

Edit: I'm not asking for htaccess rules to force https as noted in a duplicate question request. The rule I have works, the issue is specifically that when I force https, I get a infinite redirect loop.

Machavity
  • 30,841
  • 27
  • 92
  • 100
TomDowning
  • 83
  • 1
  • 6

1 Answers1

2

So for some reason, with 123-reg, you have to state redirects as follows:

RewriteCond %{ENV:SSL} !1
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
TomDowning
  • 83
  • 1
  • 6
  • Yes this is the same for a few other hosts too. Alternately (and not as good as using .htaccess) but you can [use PHP in the index.php file like this](https://gist.github.com/a1phanumeric/42e295e2b36c0febbed71d17ca3c43d7). – a1phanumeric Jun 20 '18 at 15:48