I have a website which uses wordpress. It was initially uploaded and used without SSL. After installing a server certificate and adding the apache virtualhost file for the ssl site, I tried loading the https version. It loaded with a lot of warnings about insecure content being trimmed. The resulting webpage was looking ugly because a lot of css and javascript files related to the wordpress theme were not being loaded because of insecure http protocol.

I changed the .htaccess to the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://drjoel.info/$1 [R,L]
# 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]

I then followed the codex instructions and changed the "Home" and "Site URL" in the mysql database to https from http. When I tried loading again, the browser kept showing "Too many redirects" error. I checked using verbosity and debug option in wget. This is what I get:

---request begin---
GET / HTTP/1.1
User-Agent: Wget/1.19.1 (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: drjoel.info
Connection: Keep-Alive
Cookie: __cfduid=d700f224676946c9ea07ab3eb7cf5cb861527424630

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 302 Found
Date: Sun, 27 May 2018 12:37:11 GMT
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Connection: keep-alive
Location: https://drjoel.info/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 42188807c86caaaa-SIN

---response end---
302 Found
URI content encoding = ‘iso-8859-1’
Location: https://drjoel.info/ [following]
Skipping 204 bytes of body: [<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<title>302 Found</title>
<p>The document has moved <a href="https://drjoel.info/">here</a>.</p>
] done.
URI content encoding = None
Converted file name 'index.html' (UTF-8) -> 'index.html' (UTF-8)
--2018-05-27 18:07:11--  https://drjoel.info/
Reusing existing connection to drjoel.info:443.
Reusing fd 3.

This is being repeated about 20 times before wget aborts. What's going wrong? What is the correct technique to enable SSL for a site on Wordpress?

2 Answers 2


Using a redirect from your web server isn't the best solution in my opinion.

Instead, why not fix directly the content of your database? (using https:// instead of http:// everywhere?

You could do that using a WordPress plugin such as WP Migrate DB or the command line tool WP-CLI.

Using the plugin option (WP Migrate DB), in the administration go to Tools > Migrate DB.

Using the command line tool (WP-CLI), use the following command line: wp search-replace http://oldurl.com https://oldurl.com

After applying one of these two solutions, you should have a correct site that uses https urls instead of http.


I agree with @Mike avoid http redirects and replace strings in files and DB. Another useful tool for replacig strings (even serialized), -no command line- is this one: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.