diff -Naur /root/politburo/twiki/backup/lib-20041222/TWiki/UI/View.pm lib/TWiki/UI/View.pm
--- /root/politburo/twiki/backup/lib-20041222/TWiki/UI/View.pm	2004-08-24 23:36:15.000000000 -0700
+++ lib/TWiki/UI/View.pm	2004-12-22 19:32:44.000000000 -0800
@@ -247,6 +247,9 @@
   # check access permission
   my $viewAccessOK = &TWiki::Access::checkAccessPermission( "view", $wikiUserName, $text, $topic, $webName );
 
+  # we will remember if the next if... block has redirected, in order to prevent the next one to oops and block the redirect
+  my $boumWasRedirected = 0;
+
   if( (!$topicExists) || $TWiki::readTopicPermissionFailed ) {
     # Can't read requested topic and/or included (or other accessed topics
     # user could not be authenticated, may be not logged in yet?
@@ -270,22 +273,15 @@
         my $script      = $ENV{'SCRIPT_NAME'};
         my $pathInfo    = $ENV{'PATH_INFO'};
         my $queryString = $ENV{'QUERY_STRING'};
-        $pathInfo    = '/' . $pathInfo    if ($pathInfo);
         $queryString = '?' . $queryString if ($queryString);
-        if ($script && $script =~ m|/view| ) {
-          $script =~ s|/view|/viewauth|o;
-          $url = "$TWiki::urlHost$script$pathInfo$queryString";
-        } else {
-          # If SCRIPT_NAME does not contain the name "view"
-          # the last hope is to try the SCRIPT_FILENAME ...
           $viewauthFile =~ s|^.*/viewauth|/viewauth|o;  # strip off $Twiki::scriptUrlPath
-         $url = "$TWiki::urlHost$TWiki::scriptUrlPath/$viewauthFile$pathInfo$queryString";
-         }
+         $url = "$TWiki::urlHost$TWiki::dispScriptUrlPath$viewauthFile$pathInfo$queryString";
       }
       TWiki::UI::redirect( $url );
+      $boumWasRedirected = 1;
     }
   }
-  if( ! $viewAccessOK ) {
+  if( (! $viewAccessOK) && (! $boumWasRedirected) ) {
     TWiki::UI::oops( $webName, $topic, "accessview" );
   }
 
diff -Naur /root/politburo/twiki/backup/lib-20041222/TWiki.pm lib/TWiki.pm
--- /root/politburo/twiki/backup/lib-20041222/TWiki.pm	2004-08-29 23:46:11.000000000 -0700
+++ lib/TWiki.pm	2004-12-22 19:29:04.000000000 -0800
@@ -424,7 +424,7 @@
     $includingWebName = $webName;
 
     # initialize $urlHost and $scriptUrlPath 
-    if( ( $theUrl ) && ( $theUrl =~ m!^([^:]*://[^/]*)(.*)/.*$! ) && ( $2 ) ) {
+    if( ( $theUrl ) && ( $theUrl =~ m!^([^:]*://[^/]*).*$! )  ) {
         if( $doGetScriptUrlFromCgi ) {
             $scriptUrlPath = $2;
         }
@@ -2945,6 +2945,7 @@
     $_[0] =~ s/%WIKIHOMEURL%/$wikiHomeUrl/g;
     $_[0] =~ s/%SCRIPTURL%/$urlHost$dispScriptUrlPath/g;
     $_[0] =~ s/%SCRIPTURLPATH%/$dispScriptUrlPath/g;
+    $_[0] =~ s/%VIEWPATH%/$dispViewPath/g;
     $_[0] =~ s/%SCRIPTSUFFIX%/$scriptSuffix/g;
     $_[0] =~ s/%PUBURL%/$urlHost$pubUrlPath/g;
     $_[0] =~ s/%PUBURLPATH%/$pubUrlPath/g;
