1

In order to completely move from HTTP to HTTPS, is it best practise to export the database and replace all http:// links with https://?

I did that and also made sure that 100% of the links in the database are https, which is the case now. But still I am having issues:

  1. Some links I find in my source code (actually the ones that come from wordpress functions, like wp_nav_menu()) are still returning http.
  2. When I type in my Domain https://www.example.com, WordPress redirects to http://www.example.com even though the site url is set to https.

I resaved permalinks and everything. (I also tried to install force ssl plugins, but then I get too many redirect issues since I think not all links are set to https yet)

Any hints?

Mike

1

If wordpress API gives you http instead of https it means that somewhere your data still contains HTTP, therefor you might need to take a more careful look at what urls are in your DB, for this specific functions you should look at your menus.

But probably the simplest way to solve this issue to to buffer page generation by using ob_start on init event and outputting the buffer on shutdosn after replacing all the http://mydomain to https://mydomain.

add_action('init','wpse199859_stat_buffering',0);

function wpse199859_stat_buffering() {
    ob_start();
}

add_action('shutdown','wpse199859_stop_buffering',0);

function wpse199859_stop_buffering() {
    $o = ob_get_contents();
    echo str_replace('http://mydomain','https://mydomain',$o);
}
  • Hi Mark, thanks! Actually I have searched the whole database file and cannot find any http link anymore - everything is set to https. I am not quite sure what you mean by using ob_stats. I know ob_start but I am lost on how to use this concerning my issue. Do you have a hint for this? – Mike Aug 27 '15 at 12:31
  • @Mike, yeh I misspelled it.... you just need to buffer the whole page and manipulate it before actually outputting it. once you replace all the http with https it doesn't matter much what is there in the DB or any hardcoded constatnt. Iwill try to edit the answer to make it clearer – Mark Kaplun Aug 28 '15 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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