SPUEdit

Minimum version required

The features described on this page require EZproxy 5.0 or later, excluding 5.1a and 5.1b.

EZproxy 5.1a and 5.1b have a known issue with this directive. If you need to use EZproxy 5.1 with this directive before EZproxy 5.1c is released, please contact support@oclc.org for assistance.

Overview

SPUEdit is a position-dependent config.txt/ezproxy.cfg directive that interacts with AutoLoginIP, ExcludeIP, IncludeIP, and SPUEdit directives.

Configuration

SPUEdit provides the ability to edit starting point URLs using regular expressions to allow URLs to be rearranged and then users to be rerouted to the rearranged URLs.

SPUEdit / find/ replace/ girs

where the slashes (/) can be any non-alphabetic, non-digit character; find is a Perl-style regular expression to match; replace is the string to use for replacement; and girs is an optional combination of letters used to indicate that (g) the changes should be applied globally through the URL, (i) the find string match should be case-insensitive, (r) the users should be redirected to the rewritten URL, and/or (s) SPUEdit processing should stop at this point.

The replace string may contain variables include $0 which matches the entire string that matched find, $1 through $9 based on parenthesis matching, and ${spueditvar} which is a value defined by SPUEditVar. The letter e may appear after $ to indicate that the replacement text needs to be percent-escaped as appropriate for use in URLs, such as $e0 to substitute the percent-escaped version of the find string.

For SPUEdit to be effective, the final rule must include the redirection option.

This is an example of how to remap URLs that point to http://web.somedb.com to make them point to http://www.somedb.com instead:

SPUEdit @^http://web\.somedb\.com/(.*)$@http://ezproxy.yourlib.org:2048/login?url=http://www.somedb.com/$1@ir

Note the use of @ instead of / between the find, replace, and options. If / had been used, each of the slashes that appear in the find and replace strings would need to be specified using \/ instead of just /.

While developing SPUEdit directives, you can add:

Option LogSPUEdit

to config.txt/ezproxy.cfg to direct EZproxy to record the SPUEdit manipulations of starting point URLs to messages.txt/ezproxy.msg.

Varying rules based on type of IP access

An SPUEdit directive can be set to apply only if the user's IP address falls within a current AutoLoginIP, ExcludeIP, and/or IncludeIP range. To select when a rule applies, use one of:

SPUEdit -AutoLoginIP ...
SPUEdit -ExcludeIP ...
SPUEdit -IncludeIP ...
SPUEdit -AutoLoginIP -ExcludeIP ...
SPUEdit -AutoLoginIP -IncludeIP ...
SPUEdit -ExcludeIP -IncludeIP ...

In the absence of any of these qualifiers, the SPUEdit applies regardless of the type of source IP. These qualified lines are position-dependent, so they should be arranged in config.txt/ezproxy.cfg after relevant AutoLoginIP, ExcludeIP, and/or IncludeIP directives.