Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Wordpress SSL Issue

Hi everyone,

Having an issue with installing an SSL on my Wordpress website.

I followed the instructions from Zach's SSL Wordpress course and and still having problems.

The certificate is installed correctly on the server. I have changed the site url within the "General" section in WP. My .htaccess has the following code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>

# 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

The URL for the site is:

spiritwalkjourney.com

  • Typing this redirects to https://spiritwalkjourney.com but gives a red lock error with the message: "Your connection to spiritwalkjourney.com is encrypted using a modern cipher suite. Further, this page includes other resources which are not secure. These resources can be viewed by others while in transit, and can be modified by an attacker to change the behavior of the page."

http://spiritwalkjourney.com

  • Typing this redirects to the same https://spiritwalkjourney.com but this time flashes the green lock and then turns gray. The error says the same thing with one difference: "Your connection to spiritwalkjourney.com is encrypted using a modern cipher suite. Further, this page includes other resources which are not secure. These resources can be viewed by others while in transit, and can be modified by an attacker to change the look of the page."

I use whynopadlock.com to test and it shows 12 errors:

Insecure URL: http://code.jquery.com/ui/1.11.4/jquery-ui.js?ver=1.11.4 Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/bg-pattern.png Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/138.jpg Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/122.jpg Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/110.jpg Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/John-shot-edited.jpg Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/divider.png Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/KELLY_CORSINO_web300.jpg Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/8.jpg Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/flourish-01.png Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/flourish-02.png Found in: https://spiritwalkjourney.com/

Insecure URL: http://spiritwalkjourney.com/wp-content/uploads/2015/10/Circle-Logo-2.jpg Found in: https://spiritwalkjourney.com/

When I attempt to manually try out these links they load correctly in HTTPS half of the time, and then load with Red Lock errors the other half!?!?!

This is my first time doing SSL and I have spent nearly 3 hours trying to get it to work. At my wits end here and hoping someone can help solve this issue. It just seems like my wp-content folder is not correctly connecting to HTTPS.

Thanks for the help. This community's support is so incredible!

Be well,

Joshua

2 Answers

Thank you Sue.

This helped me to find out the correct way to fix this issue.

In end I did a search and replace directly in myPHPadmin with the command:

UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://spiritwalkjourney.com', 'https://spiritwalkjourney.com');

Appreciate the help!

Thanks for answering.

I don't know about switching the "off" to "on", as on the documentation I found online had it written exactly as I have it.

As for the images, I understand that they are being served from http, I just cannot understand why it is happening. If my .htaccess is telling everything to be served in https, then why are these images still loading in http?

The strangest thing is when I click those image links, more then half of them load secure, while the others continue to load with a red lock error. It gets even stranger because in one window the image will load https with green lock and then another it will give me the red lock error again!

Sue Dough
Sue Dough
35,800 Points

Yeah I am not 100% sure about on/off. I have never set up an SSL via .htaccess. If you have apache2 it would be better/faster for your site to change the default config file. Usually located /etc/apache2/sites-available/000-default.conf . However regardless I think issue is with images. I think the issue maybe is you just changed your site settings URL and thought doing that + adding an https certificate would fix all the links in the database stored with http still.

Try running some MYSQL queries like this to switch everything. There may be more depending on your setup.

UPDATE wp_options SET option_value = replace(option_value, 'http://example.com', 'https://example.com');

UPDATE wp_posts SET guid = replace(guid, 'http://example.com','https://example.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://example.com', 'https://example.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://example.com', 'https://example.com');

Or put it in a bash script.

#!/bin/bash

mysql -u root -p yourdatabasename << END

UPDATE wp_options SET option_value = replace(option_value, 'http://example.com', 'https://example.com');

UPDATE wp_posts SET guid = replace(guid, 'http://example.com','https://example.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://example.com', 'https://example.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://example.com', 'https://example.com');

END