0

I have a wordpress website www.domain.com and we just purchased an SSL certificate but it's only working on domain.com (without the www). I have my .htaccess and site url configured

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301,NC]

and this works but the pages of my wordpress website still has links (example images www.domain.com/uploads/images/01.jpg) on my website which causes a warning for users because it's not a complete https. Is there a way to fix this other than manually editing all of the links inside the pages because this is a big website and I don't have time to edit the links one by one. Is there a plugin for this? I am also hesitant on using a plugin for this but if there's a working plugin for this I can give it a try.

I read about 301 redirect but I don't think it will work because the links are saved in the database? (im really not sure) if a 301 redirect work what is the disadvantage/advantage of it? eg. memory issue, more work for CPU?

Andrei
  • 177
  • 13
  • Plugin requests are off-topic; that said, use https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ to safely change URLs in the database without breaking serialized data. – markratledge Sep 30 '16 at 15:07

2 Answers2

0

Is there a way to fix this other than manually editing all of the links inside the pages because this is a big website and I don't have time to edit the links one by one.

Use https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ With that script, you can selectively scan your post/page content, options tables, etc., for URLs to change. This tool will correctly deserialize/reserialize data in theme options, widget options, etc., so your theme settings don't break. Using SQL queries in PHPMyAdmin or Adminer will break serialized data.

Then use the use the developer tools in Firefox (or Firebug) or Chrome or Safari or IE to see what is still insecurely loading on your site.

You may have to change hardcoded URLs in functions.php and style sheets. If there is an absolute URL in either, you can either change http to https, or remove the http: to make the URL protocol agnostic, i.e., change http://example.com/jquery.js to //example.com/jquery.js

markratledge
  • 17,322
  • 12
  • 60
  • 106
  • I've used this interconnectit product before about 2 years ago does it still work? is it reliable? this is a really huge website about 500mb files. 600 wordpress pages and 20 active plugins – Andrei Oct 03 '16 at 13:16
-1

You need to perform some requests in your DB to update all the urls stored :

  • inside your posts contents
  • for guids (urls of pages/posts/media/...)

IMPORTANT : ALWAYS save your DB BEFORE doing something like that (just in case).

Here is the requests i used to use in that case :

# change the default prefix "wp_" by your actual prefix.

# update site url in "wp_options" table
UPDATE `wp_options`  
SET option_value = REPLACE(option_value, 'http://www.oldurl', 'http://www.newurl') 
WHERE option_name = 'home' 
OR option_name = 'siteurl';



# update "guid" in "wp_posts" table
UPDATE `wp_posts` 
SET guid = REPLACE(guid, 'http://www.oldurl','http://www.newurl');



# update "post_content" in "wp_posts" table
UPDATE `wp_posts` 
SET post_content = REPLACE(post_content, 'http://www.oldurl', 'http://www.newurl');



# Update "meta_value" in "wp_postmeta"
UPDATE `wp_postmeta`  
SET meta_value = REPLACE(meta_value,'http://www.oldurl','http://www.newurl');

You just need to customize these requests with the appropriate values and perform them through PHPMyAdmin for example.

Original source of the requests : https://wpbeaches.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/

Dexter0015
  • 1,029
  • 9
  • 14
  • Bad idea to run SQL queries as those; you will break serialized data - in wp_options, theme and widget options - in the database. And plugin request questions are off-topic anyway. – markratledge Sep 30 '16 at 15:06
  • thank you for answering. would a 301 redirect solve this issue? if not then maybe I will try editing the database but I think there would be a problem with serialized data – Andrei Sep 30 '16 at 15:06
  • i don't think that any serialized data would be affected by the first request as i restrict the action of the request only on 'home' and 'siteurl' options that are not stored as serialized string : "WHERE option_name = 'home' OR option_name = 'siteurl';" – Dexter0015 Sep 30 '16 at 15:17
  • **Read** the rest of that wpbeaches blog post; it specifically states that serialized data _will break_ with that method. – markratledge Sep 30 '16 at 15:49