Category Archives: Karyx

my web development firm

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

RULE_0_START:
# 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
endif

# end rule
RULE_0_END:

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.

Subversion for web design – how we do it @ Karyx

Update: Dreamweaver CS4

The latest version of Dreamweaver (CS4 currently) now has integrated Subversion support, thankfully, which means that cloaking the .svn files is no longer necessary as DW will ignore them by default. You can configure the site to connect directly to your subversion server but in our experience unless that is a repository on the local network, it adds a painfully long pause every time you try to open a file whilst it’s checking it out from the repository. Better to use Tortoise or Versions, methinks but plus points for Adobe for incorporating this feature.

Subversion using Versions, Tortoise, Beanstalk & Dreamweaver

You can set up your own local subversion server but we find it’s easier to have our Subversion repositories hosted on the net – that way we can access them at any time. Here at Karyx we use a service called Beanstalk ( http://www.beanstalkapp.com/ ) – it lets you have a number of repositories for free and shows in a very pleasant and picturesque way all the changes that have recently taken place on the repository. You can even use it to compare different versions of files, to see where a change may have been made.

SUBVERSION CLIENTS
We recommend TORTOISESVN for pc (it integrates directly with Explorer in a context menu) or VERSIONS for mac (Versions is a brilliant piece of easy-to-use and well-engineered software). Get them here:

TORTOISE SVN (pc)
http://tortoisesvn.tigris.org/

VERSIONS (mac)
http://versionsapp.com/

SUBVERSION SET UP
Setting up a local repository can be a bit of a faff but once it’s in place, it’s pretty painless to use. Our recommended method is:

1. create an empty repository on the server (beanstalk)
2. check it out locally to a new folder on your development machine
3. copy your project files into the new folder
4. highlight the files, right-click and choose “add” to add them into your repository
5. “Commit” the files

Note that when you check out the repository, it will ask you for a destination folder. Bear in mind that both TortoiseSVN and Versions will create a subfolder with the name of your repository in it, in whichever destination folder you choose, so you can nominate your root ‘Projects’ or ‘Sites’ folders as a destination. I know this sounds a bit arcane but if you create a dedicated folder to put the repository in, you will very likely end up with a path like

c:\Projects\MyNewProject\MyNewProject\

Now you will find you have a local subversion repository that is connected to the subversion server. Any file changes within this folder will now be tracked, although you will have to “Commit” any changed files to the subversion server to make the changes official.

BASIC USE OF SUBVERSION
Subversion maintains a repository – it keeps a collection of hidden folders on your local machine that contain hashes of all the files. Whenever a file is changed from the most recent version, it makes a note of this and then when you do a “Commit” – to post changes up, it pre-selects all the affected files. You can write a comment by each commit and this is recommended as it helps when you are reviewing changes to find out what exactly you did three months ago. You can also choose to “Ignore” files and folders (3rd party applications or javascript frameworks, etc).

When other users make changes to the files, you should highlight your local folder (in Explorer | Windows), or choose the working directory (in Versions | Mac) and then choose “Update” to go and grab the latest version of the changed files. Versions helpfully indicates remote file changes in it’s file list.

DREAMWEAVER GOTCHA
Dreamweaver works pretty well with Subversion and Subversion wipes the floor with Dreamweaver’s Check-in/Check-out features. There’s a 3rd party extension you can install to do Commits and Updates but our preferred method is to use the software described above.

One thing though – if you are testing your code by deploying to a remote server and you select a folder to upload, Dreamweaver will also upload the hidden version control folders (.svn files) – not good. A work around is to download and install this extension:

http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1018603

This works by cloaking the subversion folders, so you need to have cloaking enabled in Dreamweaver. Also it’s not automatic, so when you have your basic site checked in to Subversion, you need to go to the Commands menu and then choose Cloak SCM Directories option. You will need to do this whenever you create a new directory. Alternatively, just make sure you upload selected files and not folders.

MORE ON SUBVERSION

There’s a definitive guide to subversion here:
http://betterexplained.com/articles/a-visual-guide-to-version-control/

or a “designers” guide here:
http://www.thinkvitamin.com/features/design/subversion-for-designers

and here’s some advice on commenting your commits:
http://www.wildbit.com/blog/2008/11/11/the-importance-of-commit-messages/

I hope this all helps. Subversion is definitely worth getting into if you want to stay confident in your code!

New Karyx web site is Live….

Karyx Swirl logo

Finally, after six months of me and Dan wading through reams of content, arguing the toss over logos and colourways, meticulously hand-crafting the XHTML (strict of course!) and CSS to be just so everso browser compliant, we now have a web site.

you can see it over at http://www.karyx.co.uk/

We’ve put a lot of work into getting it just right and had a lot of fun trying to manage the borders, page filling and the overhanging motif images.

I’m sure there’s still a couple of weeks’ tinkering and fiddling and general polishing of the content and presentation still to go but I’m very proud of what we’ve got so far.

Now we’ve just got to go build some sites for our clients and we’ll be laughing…