Travelling the World

Archive Page 3

I’m working on a WordPress MU blog network and ran accross the need to change the domain that the blogs are running under. This should actually be a fairly common need, for example, if you copy your PROD environment to QA, you’ll probably want to change the blog url from http://blog.com to http://qa.blog.com.

Changing the domain name starts out pretty straightforward:

  • edit the “domain” in the wp_site table.
  • edit all “domain” entries in the wp_blogs table: UPDATE wp_blogs SET domain = REPLACE(domain,”blog.com”,”qa.blog.com”)

But then, you’ll notice that there’s a lot of hard-coded urls in the wp_#_options table, which exists for every blog in your network.

So, here’s a little PHP file that you can put in the root of your WordPress MU install (or elsewhere). This will loop though these tables and do the replaces you need:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
< ?php
require_once('wp-load.php');
 
$querystr ="SHOW TABLES LIKE 'wp_%_options'";
$tables = $wpdb->get_results($querystr, ARRAY_N);
echo count($tables);
$query = "";
if ($tables){
	foreach ($tables as $table){
		$query = 'UPDATE '.$table[0].' SET option_value = REPLACE(option_value,"blog.com","qa.blog.com")';
		$wpdb->query($query);
	}
}
?>

The file will output a count of the number of tables that were affected. Ta da

At Cultural Care Au Pair we use Google Analytics to track the sucess of our campaigns both online and offline. Google provides a nice url builder tool that generates links tagged with our various campaign attributes. Here’s the problem though, the links end up looking like:

http://www.culturalcare.com/default.aspx?utm_source=testSource&utm_campaign=testCampaign

That’s quite an ugly url for something like a postcard campaign. Luckily umbraco includes a full url rewriter that can help us easily transform that into something like www.culturalcare.com/postcard

1. Configure IIS for wildcard application mapping. This allows ASP.NET to process extension-less urls (such as /postcard/):

  • right click on the umbraco website and select properties
  • go to the “home directory” tab and click “configuration”
  • in the “wildcard application maps” insert the ASP.NET dll (something like C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll ) and un-check “verify that file exists”

2. Edit /config/UrlRewriting.config in your umbraco folder

  • Change the top tag to ensure that you don’t have any conflicts with other extension-less urls (like /umbraco)
    <urlrewritingnet rewriteOnlyVirtualUrls="true"
    contextItemsPrefix="QueryString"
    defaultPage = "default.aspx"
    defaultProvider="RegEx"
    xmlns="http://www.urlrewriting.net/schemas/config/2006/07" ><rewrites>
    ...
    </rewrites>
    </urlrewritingnet>
  • add your rewrite rules following the example in the file or the documentation at urlrewriting.net. For example, if I wanted to redirect /postcard/ to /default.aspx?utm_source=testSource&utm_campaign=testCampaign I would add the following rule:
    <add name="postcard"
    virtualUrl="^~/postcard/?$"
    redirect="Application"
    rewriteUrlParameter="ExcludeFromClientQueryString"
    destinationUrl="~/default.aspx?utm_source=testSource&amp;utm_campaign=testCampaign"
    ignoreCase="true"
    />
  • Note that the & needs to be written as &amp; in the destination url.
  • If you’d like to redirect to a different domain, virtual url and redirect need to be specified accordingly:
    <add name="offsite"
    virtualUrl="^http\://(.*)my.domain/redirect/?$"
    redirect="Domain"
    rewriteUrlParameter="ExcludeFromClientQueryString"
    destinationUrl="http://offsitedomain.com"
    ignoreCase="true"
    />

Enjoy!

This Aint a Blog

Who am I kidding with posts like “Film Recommendation”? I don’t actually like to write updates very much, but here are the things that actually do change around here:

  • photos.borism.net is my friend.
  • refresh a couple of times to see different header images. There are now 202 in rotation.
  • my bookmarks and calendar in the right sidebar update themselves, hooray!

It's Been a Long Weekend

I added some more photos into the header rotation. Mostly they are from Sam and my trip to Spain and Morocco; hit refresh a couple times. :)

Film Recommendation

Film recommendation for everyone: go see word play. It’s a genuinely enjoyable film. After you get back, you can follow up with a nice read.

New Alarm Time = 5:30 AM

The internet is so full of good self improvement advice, its scary. In any case, my new alarm time is 5:30 AM thanks to How to Become an Early Riser. Today I got up at that un-godly hour out of my own volition. That means that before work I had time to:

  • sort laundry
  • mail a package
  • take some for-sale photos for craigslist
  • prepare my breakfast and lunch
  • and walk around the apartment (quietly)

I think at this rate I’ll start running out of things to do. OK, OK, this was just day one. Wish me luck.

Drowsy Chaperone

Saw the Drowsy Chaperone on Broadway this weekend. We were a little hesitant about what to go see, but thanks to Ryan’s recommendation, we landed on this show. The guys at TKTS said it got mixed reviews, though we can’t see how. The show was a riot, laugh-out-loud funny and witty.

On Sunday we went to the David Smith exhibition at the Guggenheim. The Guggenheim does a lot of things well in my opinion; nearly the whole of the collection is constantly rotating, and the museum is small enough so that you can physically see everything in a couple of hours. Bag check and the audio tour are also included as part of the admission price. Despite my previous experience of developing an audio tour system in Melbourne, this was actually the first time that I actually got to use the Antenna Audio audio tour devices that we read so much about. They were rugged, simple to use, and the production value was quite good. w00t.

Drowsy Chaperone

The Weekend @ Princeton

Some pretty hot dancing this weekend at the Princeton Ballroom Competition. Gherman Mustuc and Iveta Lukosiute didn’t mess around. They put on a full 6 or 7 dance show at the ball the night before, very impressive.

Prema and I placed 4th in Silver Swing/Mambo. And of course good times were to be had in Miles’ accord coupe during the trip there and back :) .

Princeton Competition

Ellis and Friends

Packed Ellis Paul concert at the Somerville Theater this evening. Ellis had a small band with him, and even Flynn came on stage for a few songs. Though perhaps the most memorable pieces of the evening were the songs by Antje Duvekot. I first heard her opening for Ellis at his valentine’s day concert at WPI. But this time some downloading must be done.

Went to go see the Alvin Ailey American Dance Theater last night at the Wang. What a show! The first two pieces they performed, Shining Star, and Caught were particularly strong. I’ve never really appreciated modern dance until that performance.

The theater visits Boston every spring, and is here though the weekend. Highly recommended! Many thanks to Amola for getting me to go and for the ticket!

Going to Ellis Paul tonight. woooo.