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


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 to direct EZproxy to record the SPUEdit manipulations of starting point URLs to messages.txt.

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 after relevant AutoLoginIP, ExcludeIP, and/or IncludeIP directives.