Rewrite Rules problem when rule includes homepage slug

The problem has nothing to do with the rewrite rules (though I would suggest using add_rewrite_rule() rather than the more low level approach of altering the rewrite array directly. The same for flush_rewrite_rules(). Also, although as you have it the rules are only flushed once – it would be better to do it on the activation of the plug-in, rather than inside a conditional which is checked on every page load.

… so the ‘problem’ is actually canonicalisation. Basically various urls can point to the same content (including urls with just additional forward-slashes). The idea is that

  1. This is not good for a seo perspective – if search engines don’t realise that all these url represent the same resource, they may end up competing with each other
  2. Not good from a user perspective. If they go to www.example.com?year=2012 it would be to redirect them to www.example.com/2012 – prettier and easier to remember.

So, when WordPress receives a ‘broken’ or ‘duplicate’ url such www.example.com?year=2012 it redirects it to the correct (or ‘canonical’) url. (www.example.com/2012) in this case.

One of the checks it performs is whether we are on the ‘home page’, and if we are – it checks that we are using the canonical url for our home page: http://108.166.64.229/ in your case. If not, you are redirected here. You’ll notice that http://108.166.64.229/example redirects to there to.

You can turn this off. Canonicalisation is run on the template_redirect hook. So you can simply remove it:

remove_filter('template_redirect', 'redirect_canonical');

Or you can ‘undo’ it (in the specific instance of your front say), by using a hook that is used inside the redirect_canonical callback

add_filter('redirect_canonical', 'wpse51530_redirect_canonical', 10, 2);

function wpse51530_redirect_canonical($redirect_url, $requested_url){
    if( is_front_page() )
        return $requested_url;
    else
        return $redirect_url;
}

You can see how WordPress does canonicalisation here.