* * * * *

               It's the simple things that are impossible to do

I briefly mentioned in my last post [1] 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 [2]. 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 [3], 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 (Domain Name System) 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
(Internet Protocol) 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 [4] (and
the horrors involved in debugging that [5]) and .htaccess files, so it's a
toss-up which method is more Rube Goldbergesque.

[1] gopher://gopher.conman.org/0Phlog:2009/03/27.2
[2] http://www.google.com/
[3] http://httpd.apache.org/
[4] http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
[5] http://clusty.com/search?query=debugging+mod_rewrite+rules

Email author at [email protected]