Guy Shahine's Blog

Moving my wordpress blog without losing any content

Today I decided to move my blog from to Windows Azure Websites. In this blog post I’ll explain the goal, challenges and solutions.


1. Move all content of my previous blog from godaddy hosting to Windows Azure Websites.

2. Implement URL redirects because I wanted to change the blog address from to and avoid breaking any of the indexed urls by search engines or referenced by other websites.

3. Shorten url path from /archives/{year}/{month}/{day}/{post name} to post name only.


1. I started by setting up a new wordpress blog through Windows Azure dashboard, where it was super easy to setup and here’s a detailed blog post that explains the process step by step


2. This one was a bit tricky to choose the best approach. Couple of months ago, I moved my main page ( to run on top of mvc 4 hosted on azure websites. So I searched online for url rewrite in and found this article which I skimmed through and decided to write a custom http module that listens to the “OnBeginRequest” event and manipulates the response url when the first word in the path matches “/blog” (code shared below, which includes the solution for goal #3).


3. When I initially setup my blog in 2009, I decided to pick a path that looks like this , well, my SEO (Search Engine Optimization) knowledge back then was pretty limited. Recently, I got some interest in learning more about SEO (and here’s a fantastic beginner’s guide So I wanted my new URLs to look like . WordPress, allows you to easily update the path under Settings->permalinks where they already have a predefined option for having a path with post name only but once you update the permalinks then all the old urls would stop working and return a Not Found page. So I had to update my url rewrite logic to only pick the last part of the path when applicable.


Here’s my custom http module code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Web;

    public class CustomHttpModule : IHttpModule
        public void Init(HttpApplication context)
            var beginRequestWrapper = new EventHandlerTaskAsyncHelper(onBeginRequest);

            context.AddOnBeginRequestAsync(beginRequestWrapper.BeginEventHandler, beginRequestWrapper.EndEventHandler);

        public void Dispose()
        { }

        private async Task onBeginRequest(object sender, EventArgs e)
            HttpApplication app = (HttpApplication)sender;

            if (app.Request.Path.IndexOf("/blog") == 0)
                var splitPath = app.Request.Path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                string postName = splitPath.Length > 1 ? splitPath.Last() : string.Empty;

                var newUrl = new Uri(new Uri(""), postName);

                app.Response.RedirectPermanent(newUrl.AbsoluteUri, true);

And you need to reference your custom module in your web.config

Removed for brevity
      <remove name="FormsAuthentication" />
      <add name="CustomHttpModule" type="," preCondition="managedHandler" />

I hope you find this interesting!


Don’t Be a Turkey

Today is Thanksgiving day, which is probably the second most popular holiday in the US where families get together and feast on a turkey, mashed potatoes, gravy and jelly, followed by a pecan or pumpkin pie with lots of whip cream. Here’s a comic about Thanksgiving by Matthew Inman

When I hear “turkey”, it always reminds me of a story that I first read few years ago in a book called The Black Swan by Nassim Nicholas Taleb. A story that I’ve told multiple times (I have my own version now with all the salt and pepper), it goes like this: A turkey wakes up hungry, and furiously searches for food until she finds some in the corner.  Same deal the second day until she finds more food in the same spot. Fast forward few weeks, the turkey doesn’t think about food anymore, when she’s hungry she knows where to go. The turkey’s life is amazing, she’s never hungry, she can now focus on other activities until one day around the end of November, she’s snatched from her little heaven and a butcher is about to do his little business.


The moment before the knife touches the turkey’s throat, she’s in shock, and she’s wondering why. How could you blame her? she didn’t do anything wrong, and there is no way she could’ve seen this coming. This goes to all of us, I smile and remember the turkey story when I hear someone saying things like “Ohh my boss said that I’m on a fast track for a high position” or “I have a stable job at company X, their stock is getting more gain”. Find a good balance in your life, don’t take shortcuts and don’t get carried away by the little details. There is a favorite quote from a Kevin Spacey movie “You can’t win a marathon without putting some bandaids on your nipples”

To help you remember not to be a turkey, I wanted to hire miss Turkey but hardee’s beat me to her

Happy Thanksgiving, Don’t be a turkey my friend.

CloudCamp Seattle

Few weeks ago, I attended the CloudCamp event that was held at the Amazon headquarters in Seattle. For anyone who couldn’t make it, here’s my take:

The event started with a 5 min talk by the main sponsors (For more details about the speakers, check out the schedule at CloudCamp Seattle):

Amazon: The presenter pitch was around the idea that the cloud is secure and that the concept might have changed. Historically, you probably were able to point at or hug your machines and call them yours, but once you connect them to the internet, the question becomes “are they secure?”. Steve believes that the statement “the Cloud is insecure” is not true, “what’s secure anyway?”

IBM: I was so happy to know for the first time where IBM is partially heading toward, they’ve been talking about cloud and green earth and those nice commercials for months but on the technical ground I didn’t see a defined story. During Tony’s (who’s not a technical guy, he’s more of a sales/business person) presentation, it was a product pitch about what they call WebSphere CloudBurst/Hypervisor Editions (ouuu fancy name). Here’s the one sentence that summarizes his whole 7 minutes talk “They provide an appliance (the size of a pizza box, he said it like 10 times) that you connect to your network and machines, and what it provides a Front End between you and your machines sitting in your own data center or lab to spin up Virtual Machines and control the environment”

Windows Azure: The presentation was an overview of the Windows Azure Platform features. I wish the talk was around how Windows Azure brings value as a cloud platform. Well, I guess there is very little that you can squeeze in a 5 minutes talk.

Skytap: it was a pure product pitch delivered in a super boring manner. Their website has an overview of what they do, the presentation didn’t bring any value other than repeating this description.

Atlantic.NET: NO SHOW

Hubspan: Business talk, the presenter was really funny and the presentation was engaging. The talk was mostly addressed to business owners/investors and pretty much how the cloud can promote the old business model.

Guest Speaker: Patrick from a local company (forgot the name) that runs financial profiling to give you advice on the stock/mutual funds/… that you need to invest in. If you’re curious: I chatted with the dude, and they don’t take customers with less than a million dollars in investment

Then we moved to the Unpanel section where the audience asked 9 questions related to cloud: 6 answered by people who called themselves cloud experts, 3 answered from the audience (1 of them by me). Example questions: In the light of wikileaks being kicked out by Amazon, where does cloud stand providers stand ? Where do you think the NoSQL database is heading toward? Name one type of business or firm that can’t move to cloud, and give facts? Where does cloud stand on multiple geo located databases and how do you keep them in sync? Where does cloud stand in the open source community? … etc

Finally the unconference time came where around 7 people from the audience suggested topics to chat about. Some of the topics were: Cloud APIs, Open source community, Windows Azure 101, Google Webservices 101, CloudDatabase discussion … others

That’s it, let me know if you have any questions.