From 1c388b2a48ded4c99cbcf632550dafd46851b23d Mon Sep 17 00:00:00 2001 From: Uriel Date: Mon, 5 Jan 2009 05:41:10 +0100 Subject: [PATCH] Make perm redirect code a bit simpler and a bit less hideous. --- bin/werc.rc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/werc.rc b/bin/werc.rc index 07af18a..af08818 100755 --- a/bin/werc.rc +++ b/bin/werc.rc @@ -219,13 +219,13 @@ for(i in ('' $args)) { cd $werc_root # Redirections and other preprocessing -if(~ $#redirectPermanent 1) +if(~ $#redirectPermanent 1) { perm_redirect $"redirectPermanent - -if not if(~ $#redirectPermanent 2 && {echo $SERVER_NAME^$req_path|grep -s $redirectPermanent(1) }) { - # Experimental regexp sub-based redirect, probably should find a nicer interface - to=`{echo $SERVER_NAME^$req_path|sed 's@'^$redirectPermanent(1)^'@'^$redirectPermanent(2)^'@'} - if(! ~ $to $req_path) +} +if not if(~ $#redirectPermanent 2) { + from='http://'^$SERVER_NAME^$req_path + to=`{echo $from|sed 's@'^$redirectPermanent(1)^'@'^$redirectPermanent(2)^'@'} + if(! ~ $to $from) perm_redirect $to }