301 Redirects With A Zeus Server

Over the last couple of weeks I have been working on a site powered by a Zeus Web Server. Part of the work undertaken was upgrading the site from it’s old ecommerce design querylink structure to new clean, seo friendly urls and also sort out any canonicalisation conflicts that were present.

Unlike Apache, where there is a vast array of information available online for people wanting to run redirect scripts – there is a distinct lack of articles relating to Zeus in respect of redirects. So, I thought I would output the proper way to code redirect scripts for a Zeus server.

Canonical issues: www vs. non-www for a Zeus Server, replace yourdomain with the name of your domain.

#— matches any subdomain except www, be redirected to ‘www’ —

match IN:Host into $ with ^yourdomain\.co\.uk$
if matched
match URL into $ with ^/(.*)$
if matched
set OUT:Location = http://www.yourdomain.co.uk/$1
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
goto END
endif
endif

301 redirection script for a Zeus Server

#— 301 Redirect —

match URL into $ with ^/old.html$
if matched
set OUT:Location = http://www.yourdomain.co.uk/new.html
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
goto END
endif

And that’s it, have fun and remember these redirect scripts are for the Zeus Server only. Please remember and always test your work when running redirect scripts.

Comments

12 Responses to “301 Redirects With A Zeus Server”
  1. Frank Malina says:

    Where should I place this text?
    I suspect Zeus won’t read it from the .htaccess file.

  2. admin says:

    I normally create a file called rewrite.script and place your redirects in there then upload it to the server Frank.

    If that doesn’t work contact your hosting company and explain that you need the rewrite script engine to be turned on in your Zeus server.

    Hope this helps.

    Paul

  3. John Dixon says:

    Thank you. I’ve been scratching my head with this one for a few days now. In the spirit of sharing, this is the script I used when I migrated a site from IIS and .asp to .php – it rewrites URIs and preserves querystring values.

    # Rewrites URIs with .asp suffix to .php and preserves querystring values
    insensitive match URL into $ with ^(.*)\.asp(.*)$
    if matched
    set URL = $1.php$2
    set RESPONSE = 301
    set OUT:Location = %{URL}
    set BODY = Please try here instead\n
    goto END
    endif

  4. John Dixon says:

    It’s translated a bit of code that has a link on it. I’m just going to try it with entities instead:

    set BODY = Please try here instead\n

    Otherwise (in case this doesn’t work either) just:

    set BODY = Moved

    as in the examples you gave.

  5. John Dixon says:

    And finally, the reverse of your script, which converts www into non-www addresses:

    # Rewrites www to non-www equivalent addresses
    insensitive match IN:Host into $ with ^www\.[domain]\.co\.uk$
    if matched
    match URL into $ with ^/(.*)$
    if matched
    set URL = [domain].co.uk/$1
    set OUT:Location = %{URL}
    set OUT:Content-Type = text/html
    set RESPONSE = 301
    set BODY = Please try here instead\n
    goto END
    endif
    endif

  6. John Dixon says:

    Same thing happened with the set URL = line. There was a dollar sign missing after the final forward slash and before the number 1. Hopefully a few bits of Unicode will help (fingers crossed as there’s no preview):

  7. Gav says:

    Hi,

    I have a site which has directories that I would like to use 301 Redirects with as follows:-

    www mysite.com/categories/
    www mysite.com/products/

    Is it possible to place a rewrite.script within each of these folders to basically do two things:-
    1 – Redirect the user to www mysite.com
    2 – Tell Google that the directory has permanently removed

    Does anyone have any idea on how this would be achieved – thanks again.

  8. admin says:

    Gav the script above should handle that for without any worries, here’s a further example of what you should be doing…

    #— 301 Redirect —

    match URL into $ with ^/categories$
    if matched
    set OUT:Location = http:// www mysite.com/
    set OUT:Content-Type = text/html
    set RESPONSE = 301
    set BODY = Moved
    goto END
    endif

    I have placed spaces in this line : set OUT:Location = http:// www mysite.com/ to stop it linking out to 404 error please close up the spaces before you run your code

  9. Gav says:

    Awesome – thanks for your help on this I was pretty much lost until I found this website!

    Thanks again your help is much appreciated! :)

  10. Barbara says:

    Thank you such much for script for www versus non www. It worked instantaneously – and that never happens! First break of the day!

  11. Liam says:

    Great post.

    If I had 8 crawl errors on my site because I move stuff into a webfolder – would I need to write a 301 redirect for ‘each’ URL and place it in the rewrite.script file or can I write 1 that covers them all?

    • Paul Steven says:

      Hi Liam, it depends, if your not bothered about passing the existing pagerank or pagestrength to the new pages then you could do just a folder redirect, however, if you want to hold onto some pagestrength then I would advise 8 singular redirects to help accomodate any incoming or inbound links you have pointing to the site (although, tbh, to get the full credit always try and get the 3rd party that is linking to you to repoint the link to you new destination).

      Hope this helps,

      Paul

Recent Entries

Shout Outs

Worth A Look

follow nsm on twitter
follow nsm by rss
connect with nsm on facebook