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.