1.5M ratings
277k ratings

See, that’s what the app is perfect for.

Sounds perfect Wahhhh, I don’t wanna

Wordpress Tip: How to rewrite HTTP into HTTPS urls WITHOUT htaccess

If you are in need of rewriting HTTP URLs stored in your Wordpress database installation and don’t want to manually change them into HTTPs this little trick can be useful to you.

In my case, I needed to change all the URLs of the attachments of posts like this “http://mydomain.com/files/2012/11/image01.jpg” to HTTPS. If there were a simple installation I would manually changed it by hand in the database but these case envolves a Multisite Wordpress with hundreds of blogs and multiple posts.

How did I solve it? Wordpress Filters came to the rescue. This is how I solve it in the “functions.php” of the theme:

function changeToHTTPS($url) {
   $return = str_replace('http://mydomain.com', 'https://mydomain.com', $url);
   return $return;
}
if (defined('FORCE_SSL_LOGIN') && FORCE_SSL_LOGIN) {
    add_filter('wp_get_attachment_url', 'changeToHTTPS');
}

Wordpress