The file is computed sequentially and as soon as a rule (regex_pattern) matches, the resolution is stopped and the remaining lines are not computed any more.
It is recommended to define a final rule that matches everything using the .* regex_pattern and a target with a meaningful hint to the user or to the root of the web server.
If no such final rule is defined that matches everything, there is no response to the user (no web browser is started).
The format of each line is:
rule_identifier ; regex_pattern ; target ; [ viewer ; ]
(leading and tailing white spaces between the field and the separator ; are trimmed away).
This identifier can also be used when doing a regression test of the defined rules in a map file against an input file containing a list of file names in conjunction with -f - .
Remember: when a rule matches, the remaining rules are not resolved any more.
See: regexintro(4) for a short introduction to regular expressions.
Be aware, that a backslash ( \ ) as present in Windows™ file names have to be escaped in regular expressions ( \\ ).
Therefore the regular expression to match the file g:\data\project\calc.xlsx is g:\\data\\project\\calc\.xlsx .
Backslashes ( \ ) in the target definition are translated to slashes ( / ).
The target configuration can hold several @NAME@ placeholders that are replaced with a content resolved from the given filename thru the -f option:
The given filename g:\research\projects\Alpha\report.doc or the UNC variant example \\filesvr\share\research\projects\Alpha\report.doc would set @FOLDER:1@ to research, @FOLDER:2@ to projects and @FOLDER:3@ to Alpha.
Hint: For the UNC variant @FOLDER:0@ is set to share.
This allows to open the redirected files (for example based on suffix) in different applications.
Also if a web application runs best in 'Internet Explorer' and another runs best in Firefox the viewer command can be defined for a specific rule.
In the viewer field setting the environment variables %USERNAME%, %USERPROFILE%, %ProgramFiles%, %ProgramFiles(x86)%, %APPDATA%, %INSTALLDIR%, and %INSTALLDRIVE% can be used.
The following map file shows how it is possible to define direct mappings and also to support some cleanup during migration where some source folders are migrated to different destination locations:
# # redirect2web.map - map file for redirect2web # # [00] 07.06.2017 CWa Initial Version # [01] 08.06.2017 CWa ++ # #id ;regex_pattern ;target; EXMP-01;(\\\\filesv\\data|g:)\\acct\\LToons\\.*;http://spoint.acme.ch/f/accounts/ACME/; EXMP-02;(\\\\filesv\\data|g:)\\acct\\.* ;http://spoint.acme.ch/f/accounts/@FOLDER:2@/; EXMP-11;(\\\\filesv\\data|g:)\\cust\\Stone\\.* ;http://spoint.acme.ch/f/accounts/Quarry Inc/; EXMP-12;(\\\\filesv\\data|g:)\\cust\\.* ;http://spoint.acme.ch/f/accounts/@FOLDER:2@/; LAST ;.* ;file:///@INSTALLDIR@/lib/redirect2web.html;
In general you would define and create an own
information
html
page (most likely residing on a web server
or a central file location) to inform your users more
specific.
Of course you can also use anchors ( e.g.
acme-migration-info.html#INTRO
) to jump to a specific part of the information
html
page.
EXMP-22;(\\\\filesv\\data|g:)\\(acct|cust)\\.* ;http://spoint.acme.ch/f/accounts/@FOLDER:2@/;
The following redirect2web.cfg config file expands the PATH to Firefox browser installations and sets the default viewer to Firefox.exe.
The map file redirect2web.map is located on the network drive g:\ to allow central editing/enhancement of the map file without the need to distribute the changed map file to users:
# # redirect2web.cfg - configuration file for redirect2web # # [00] 24.06.2017 CWa Initial Version # MAPFILE=g:\migration\redirect2web.map PATH=%USERPROFILE%\Documents\bin\FirefoxPortable;d:\bin\FirefoxPortable VIEWER=FirefoxPortable.exe
To speed up rule writing, it is recommended to set the most used viewer in the VIEWER=command setting in redirect2web.cfg and the exceptions in the viewer field in the redirect2web.map configuration file:
# # redirect2web.map - map file for redirect2web # # [00] 24.06.2017 CWa Initial Version # #id ;regex_pattern ;target ;viewer; EXMP-40;g:\\(acct|cust)\\.*;http://sharepoint.acme.ch/f/accounts/@FOLDER:2@/;iexplore.exe; EXMP-41;g:\\manuals\\.* ;http://opendocman.acme.ch/man/; EXMP-42;g:\\project\\.* ;http://openproject.acme.ch/prj/@FOLDER:2@/; EXMP-43;i:\\checklists\\.* ;http://foswiki.acme.ch/; LAST ;.* ;file:///@INSTALLDIR@/lib/redirect2web.html;
This is free software; see WA2LWinTools/man/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.