Skip to content

Instantly share code, notes, and snippets.

@yoander
Last active Jun 26, 2017
Embed
What would you like to do?
<?php
// Check if a redirect is needed
$redirect = !isset($_SERVER['HTTPS']) || ('on' != $_SERVER['HTTPS']);
$redirect = $redirect || !isset($_SERVER['HTTP_X_FORWARDED_PROTO']) || ('https' != $_SERVER['HTTP_X_FORWARDED_PROTO']);
// Permanent redirect to https version
if ($redirect) {
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], true, 301);
exit();
}
UPDATE tableprefix_posts
SET
post_content = REPLACE(post_content, 'http://www.midominio.com', 'https://www.midominio.com'),
post_excerpt = REPLACE(post_content, 'http://www.midominio.com', 'https://www.midominio.com')
WHERE post_content LIKE '%http://www.midominio.com%' OR post_excerpt LIKE '%http://www.midominio.com%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment