Skip to content

Instantly share code, notes, and snippets.

@yoander
Last active June 26, 2017 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoander/1c15eea63875c667b085267ec9720ea7 to your computer and use it in GitHub Desktop.
Save yoander/1c15eea63875c667b085267ec9720ea7 to your computer and use it in GitHub Desktop.
<?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