Skip to content

Instantly share code, notes, and snippets.

@emachnic
Created October 20, 2014 20:12
Show Gist options
  • Save emachnic/3603e4bfc5cd7e554b45 to your computer and use it in GitHub Desktop.
Save emachnic/3603e4bfc5cd7e554b45 to your computer and use it in GitHub Desktop.

Done

DONE:

  # NEW 20040713 /images and /banners are local
  # CHANGED 20060123 added feeds-local
  # CHANGED 20060216 added css & js
  # CHANGED 20080324 blog (new) is local
  # 20080701 For-pay demo is local
  if ( $uri =~ m#^/(images|banners|feeds-local|css|js|blog|w3c)/# ) {
      $uri = "LOCAL:$uri";
  }

  # CHANGED 20040707 handle "REDIRECT:" special case
  # CHANGED 20040713 handle "LOCAL:" special case
  if ( $uri =~ m/^(REDIRECT|LOCAL):/ ) {
      $redir = $uri;
  }
  else {
      $redir = "backend.neighborhoodlink.com$uri";

  #
  # Mangle the query string if necessary.  Query string sometimes
  # contains MIME-escaped characters, e.g. the "mail this page to a friend"
  # link gives a query string of "location=%2Fpublic%2Fmain2.html&qry=etc"
  # and we had to unescape those in the Rewrite rule (see httpd.conf) in order
  # to avoid "%2" being read as a backreference.  So, now we have to escape
  # the little bastards again.  Capisci?
  #
      if ( $qs =~ m/^location=(.*)&qry=(.*)$/ ) {
          $qs = "location="
            . uri_escape( $1, "&=" ) . "&qry="
            . uri_escape( $2, "&=" );
      }
      $redir .= "?$qs" if ($qs);
  }

Reallydone

REALLYDONE:

  &debug("final redirection: $redir");
  print "$redir\n";
  &logtest("$orig $redir");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment