Tag Archives: namesco

NamesCo Zeus server, 301 Redirects

Howto manage a 301 redirect on a NamesCo linux (Zeus) server

I felt I should write this up because it’s a problem that’s been puzzling me for some time and I only found out the answer today. Here’s the deal:

* it’s currently recommended that all traffic to a web site goes to one URL, to minimise dilution of the Google PageRank.

* on NamesCo servers, traffic is automatically routed to both http://www.example.com/ and http://example.com

* ordinarily I would use an Apache .htaccess script with a simple 301 redirect in it, like so:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

* But…. NamesCo servers don’t run on Apache, they run on Zeus

So what we need is a script that will force Zeus to do the same kind of redirect.

There’s just one other gotcha, that is specific to NamesCo. The script is only allowed to be run from one place, in the root of your web directory, a file called rewrite.script. You can edit this manually but by far the best way to manipulate it is via the control panel on the NamesCo server. There’s a module under Scripts & eCommerce called Rewrite Script.

Screen grab of NamesCo control panel

Screen grab of NamesCo control panel

This module has two key features:

1) it will take standard UrlRewrite code from an Apache .htaccess file and convert it to Zeus compliant code.

2) it will allow you to type in Zeus compliant code and validate it before writing it to the server root.

After much scrabbling around and an awful lot of trial and error, I found a post from a guy called Robert at www.emailmarketingsolution.co.uk that seemed to do the trick. The original post is up on the zeus community knowledge hub.

Zeus uses a completely different algorithm for its server control scripts and documentation is somewhat thin on the ground – most of the examples I found on the internet were just that, examples and hacks showing different approaches to solving pretty much the same problem.

I’m going to repeat Robert’s script here but add in a bit of background detail to show what it is actually doing

# begin rule, rules are separated into blocks in the Rewrite.Script
match IN:Host into $ with ^example\.com$
# examine the hostname to see if it doesn’t begin with www (note the backslash to escape the dot before the domain suffix)

if matched then
match URL into $ with ^/(.*)$
# if there is a match, extract the rest of the path into a temporary variable ($1)

set OUT:Location = http://www.example.com/$1
# now re-construct the header location, this time prefixing it with ‘www’

set OUT:Content-Type = text/html
set RESPONSE = 301
# tell Google (& others) that this page has been permanently moved, so they update their records

set BODY = Permanently Moved
# human readable version of ’301′ message

goto END

# end rule

OK, so there you have it. That’s how to do some basic Zeus wrangling. There’s more documentation on the Zeus server at the Zeus Knowledge Hub web site. I think the key documentation is the TrafficScript Guide but I’m not entirely convinced.

Additional: DRUPAL users
There’s also a complete Rewrite.script for Drupal users. Get it from the main Drupal web site.