Quantcast
Channel: Keep Calm and Carry on Coding » Blogger
Viewing all articles
Browse latest Browse all 2

Auto Redirect from Blogger to WordPress

$
0
0

Here’s a useful bit of Javascript that will redirect your old Blogger blog account to your new, self hosted WordPress blog account once you’ve imported all your old blogs.

It uses the search function in your new account to list the possible matches (usually just the correct one!). It works this way because the blog names on blogger are rarely the same as in wordpress, but it encourages people to update their links by showing them it’s different. It also displays a helpful message.

First go to your blogger account, select “Design” tab and “Edit HTML”. To get javascript in there, you’ll need to turn on “Expand Widget Templates”, and make sure any code is properly escaped, like the example below.

Now copy this piece of code, as is (except for line numbers), just after the Body tag:

  1. <h1>Blog has moved, searching new <a href='YOURBLOG'>blog</a>...</h1>
  2. <script type='text/javascript'>
  3. var splits = location.href.split(&quot;/&quot;);
  4. var splits2 = splits[splits.length-1].split(&quot;.&quot;);
  5. var search = splits2[0].replace( /-/g, &quot;+&quot; );
  6. window.location = &quot;YOURBLOG/?s=&quot; + search;
  7. </script>

Now replace YOURBLOG with the address to your blog (e.g. http://blog.akademy.co.uk )

Test it by going to one of your old Blogger blogs.

A helpful page at http://www.blogcrowds.com/resources/parse_html.php


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images