The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Friday, March 27, 2009

It's the simple things that are impossible to do

I briefly mentioned in my last post something about <shudder> control panels and redirects requiring rocket science. It's true.

Several months ago a client wanted to improve their search engine rankings with Google. Their current configuration at the time was:

<VirtualHost 10.10.10.10:80>
  ServerName  www.example.com
  ServerAlias example.com
	...
</VirtualHost>

Their site reponds to both www.example.net and example.net, and while we can see they're the same site, technically speaking, search engines treat them as two separate sites. In fact, they pretty much have to, as they're, again, technically, under two different names and in theory, there could be a different site under each name.

Now the problem—while Google can probably figure this out, there's no indication to Google as to which “site” is the proper location, so it calculates the page rank for example.net separately from www.example.net, thus diluting the pagerank for the entire site.

There is a way of telling Google which site is considered “the site” and it involves redirecting requests at “the lesser site” to “the site.” The easiest way of doing this, using Apache, is:

<VirtualHost 10.10.10.10:80>
  ServerName example.com
  Redirect   permanent http://www.example.com/
</VirtualHost>

<VirtualHost 10.10.10.10:80>
  ServerName www.example.com
	...
</VirtualHost>

And now every request to a page at example.com will be redirected to “the site” at www.example.com. Simple, trivial, and therefore, impossible to do via a control panel!

When I tried that very method on the webserver (which has a <shudder> control panel on it), I broke the entire webserver!

And sadly, there is no option to set this up under the <shudder> control panel. Sure, you can set an alias for the site, but that gets slapped under the ServerAlias directive, which is not what the client wanted (as that's what the client had currently and wanted changed).

We got it working, but it involves a secondary webserver (without a XXXXXXXXX control panel on it) and changes to DNS files. Here's how it works.

The client tells us which address is “the site” and which should be redirected. For our example, we're redirecting example.com to www.example.com. We then edit the DNS file for their domain and set the IP address for example.net to our non-control panel webserver.

Then, on our non-control panel webserver, we add:

<VirtualHost 10.10.10.10:80>
  ServerName example.com
  Redirect   permanent http://www.example.com/
</VirtualHost>

to the configuration. It works, and it's only slightly Rube Goldbergesque.

And yes, there's a solution that could be done on the server with the <shudder> control panel, but that involves mucking with mod_rewrite (and the horrors involved in debugging that) and .htaccess files, so it's a toss-up which method is more Rube Goldbergesque.

Obligatory Picture

[It's the most wonderful time of the year!]

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: http://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

http://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2019 by Sean Conner. All Rights Reserved.