A week ago I decided to speed up the blog by making a new one… if only I had known exactly what work it would entail I may have decided to stick with a very slow blog instead.
Yet, no, I decided to make a go of it. I have had to hack my .htaccess file to get redirects from older pages to go to the Archive Blog as well as making sure that all of the items, past, present and future are available via the RSS links on this blog.
And here we are. With the exception of searching across multiple blogs, the site is where it should have been a week ago.
In order to get the recirects working, I editied the .htaccess file and added the following lines -
-
<ifmodule mod_rewrite.c>
-
RewriteCond %{REQUEST_URI} ^/(2002|2003|2004|2005|2006|2007|2008|2009)/ [nc]
-
RewriteCond %{REQUEST_URI} !/2009/08/(19|20|21|22|23|24|25|26|27|28|29|30|31)/ [nc]
-
RewriteCond %{REQUEST_URI} !/2009/(09|10|11|12)/ [nc]
-
RewriteRule ^(.*)$ archive.wiredpig.us/$1 [R=301,L]
-
</ifmodule>
What this does is look at the incoming requested URL and, if its from before 08/19/2009 it redirects the request the same path in the new blog(1) .
Then I had an issue of search engine users being dropped off at /TAG pages that do not exist. Now I needed to hack the themes 404(link) page to give these people an option of clicking a couple of links to get them to their final destination.
To accomplish this I added code to the 404(link) template that checked if the person came from the blog (this would be unlikely, but possible). It then looked at the Search String that came with the user (assuming that they came from a search engine) and it extracted the string.
Next it pulled the requested URL and added it to the end of the Archive Blog’s URL allowing them to click there or, alternatively, I added the search string to the Archive Blog’s search URL allowing the user to search the Archive Blog.
The most likely solution, for the user, is to click the first link and go to archive.wiredpig.us/(URL they landed on originally) but I wanted to give them a few options.
-
< ?php get_header(); ?>
-
< ?php get_sidebar(); ?>
-
< ?php /* <h1 class="title">Not Found */ ?>
-
<div class="single">
-
<div class="title">
-
<h2>Woah!</h2>
-
</div>
-
<div class="cover">
-
<div class="entry">
-
<p>The page you are looking is not here… but its VERY CLOSE!!</p>
-
-
< ?php
-
$yoursite = "blog.wiredpig.us"; //Your site url without http://
-
$yoursite2 = "wiredpig.us"; //Your site url without http://
-
$referer = $_SERVER[‘HTTP_REFERER’];
-
-
//Check if browser sends referrer url or not
-
if ($referer == "") //If not, set referrer as your domain
-
$domain = $yoursite;
-
else
-
$domain = parse_url($referer); //If yes, parse referrer
-
if($domain[‘host’] != $yoursite || $domain[‘host’] != $yoursite2) { ?>
-
<p>Your searched for <strong>
-
< ?PHP
-
$referer = $_SERVER[HTTP_REFERER];
-
IF($referer)
-
{
-
PREG_MATCH("/[&?]q=([^&]*)/", $referer, $matches);
-
IF($matches[1])
-
{
-
$search_query = RAWURLDECODE($matches[1]);
-
$search_query = STR_REPLACE("+", " ", $search_query);
-
}
-
}
-
PRINT "’$search_query’";
-
?>
-
</strong>.</p><p>
-
</p><p>All entries before August 18, 2009 have been moved to the <a href="http://archive.wiredpig.us">Archive Blog</a>.<ul><li>It is <strong>most likely</strong> that the article you’re looking for is at <strong><a href="http://archive.wiredpig.us<?php echo $_SERVER['REQUEST_URI'];?>">this link</a></strong>.</li><li>Clicking <strong><a href="http://archive.wiredpig.us/?s=
-
<?PHP
-
$referer = $_SERVER[HTTP_REFERER];
-
IF($referer)
-
{
-
PREG_MATCH("/[&?]q=([^&]*)/", $referer, $matches);
-
IF($matches[1])
-
{
-
$search_query = RAWURLDECODE($matches[1]);
-
/* $search_query = STR_REPLACE("+", " ", $search_query); */
-
}
-
}
-
PRINT "$search_query";
-
?>
-
">this link</a></strong> will <strong>run your search</strong> terms on the Archive Blog.</li></ul></p>
-
< ?php } else { ?>
-
<p>Oops…. We cant find that page.</p>
-
<p>Maybe a little searching will help resolve the issue.</p>
-
<p>
-
<form method="get" id="searchform"
-
action="<?php bloginfo(‘home’); ?>/">
-
<input type="text" value="<?php echo $search_text; ?/>"
-
name="s" id="s"
-
onblur="if (this.value == ”)
-
{this.value = ‘< ?php echo $search_text; ?>‘;}"
-
onfocus="if (this.value == ‘< ?php echo $search_text; ?>‘)
-
{this.value = ”;}" />
-
<input type="hidden" id="searchsubmit" />
-
</form>
-
</p>
-
< ?php } ?>
-
</div>
-
</div>
-
</div>
-
-
< ?php get_footer(); ?>
Once that was done I headed over to Yahoo Pipes(link) and created three new pipes. These ended up combining the various feeds I had originally(2) with the feeds from here. This allows the user seamless access to all the content regardless of where it is(3)
And now you have this… but hey… it runs faster!
The only thing left ‘to do’ cross site search… maybe next week.
Footnotes:
Footnotes are for reference only and may have little, if anything to do with the text from the post.
- Thats on great benefit of using date based path names in WordPress. [↩]
- Now at Archive [↩]
- Somewhere between the two blog spaces. [↩]
Exciting, huh?
Popularity: unranked



































