Skip to content

Instantly share code, notes, and snippets.

@jamesjara
Last active August 29, 2015 14:17
Show Gist options
  • Save jamesjara/ef943e7939eac49bd42c to your computer and use it in GitHub Desktop.
Save jamesjara/ef943e7939eac49bd42c to your computer and use it in GitHub Desktop.
SEO 301 Redirect BLOGSPOT to Wordpress
<?php
$parse = parse_url($_GET['a']);
$parse['host'] = 'www.jamesjara.com'; //your new domain
$parse['scheme'] = 'https';
$fixed = str_replace('.html','/',unparse_url($parse));
function unparse_url($parsed_url) {
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
$user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
$pass = ($user || $pass) ? "$pass@" : '';
$path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
$query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
return "$scheme$user$pass$host$port$path$query$fragment";
}
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: ".$fixed);
Add to your blogspot blogger template
<meta expr:content='"0; url=http://www.jamesjara.com/redirect.php?a=" + data:blog.url' http-equiv='refresh'/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment