Wusage's documentation on the usage of Regular Expressions is not well documented. There were no examples to write Regular Expressions with Replacement using Backreferences.
NOTE: Wusage's regular expression must begin with @
After some trial and error, here is what I have learnt.
Example 1:
URL to match:
/flash/header.swf?rnd=0.24753951619780357
Regular expression:
@^([^\.]*\.swf)\?.*$
Replacement expression:
\1
Returns the entire string matched by the regular expression, e.g. /flash/header.swf?rnd=0.24753951619780357
\2
Returns the first sub-match, e.g. ([^\.]*\.swf)
, /flash/header.swf
Example 2:
URL to match:
/resize_image.aspx?FilePath=/resource_docs/SEA_Sewar.jpg&width=640
Regular expression:
@^/resize_image\.aspx\?FilePath=([^\.]*\.(jpg|gif|tif|bmp))&.+$
Replacement expression:
\1
Returns the entire string matched by the regular expression, e.g. /resize_image.aspx?FilePath=/resource_docs/SEA_Sewar.jpg&width=640
\2
Returns the first sub-match, e.g. ([^\.]*\.(jpg|gif|tif|bmp))
, /resource_docs/SEA_Sewar.jpg
Wusage's config file snippet:
#Rewrite Rules...
rewrite
# /flash/header.swf?rnd=0.24753951619780357
# /flash/header_exhibition.swf?rnd=0.7556053221950332
# /flash/header_learning.swf?rnd=0.0028210814865592404
# /flash/header_visitus.swf?rnd=0.01042118194914482
url @^([^\.]*\.swf)\?.*$ \2
# /resize_image.aspx?FilePath=/resource_docs/SEA_Sewar.jpg&width=640
url @^/resize_image\.aspx\?FilePath=([^\.]*\.(jpg|gif|tif|bmp))&.+$ \2
url /exhibitions/events.asp?* /exhibitions/events.asp
url /exhibitions/eventdetail.asp?* /exhibitions/eventdetail.asp
url /exhibitions/exhibitions.asp?* /exhibitions/exhibitions.asp
url /exhibitions/booking.asp?* /exhibitions/booking.asp
url /exhibitions/thankyou.asp?* /exhibitions/thankyou.asp
url /exhibitions/booking_clear.asp?* /exhibitions/booking_clear.asp
url /exhibitions/ticketdetail.asp?* /exhibitions/ticketdetail.asp
url /booking/login/loginaction.asp?* /booking/login/loginaction.asp
url /booking/payment/add_booking.asp?* /booking/payment/add_booking.asp
url /booking/report/attendence.asp?* /booking/report/attendence.asp
url /booking/report/payment_details.asp?* /booking/report/payment_details.asp
url /booking/report/details.asp?* /booking/report/details.asp
url /booking/payment/details.asp?* /booking/payment/details.asp
url /booking/report/excel_details.asp?* /booking/report/excel_details.asp
url /booking/report/excel_payment_details.asp?* /booking/report/excel_payment_details.asp
url /pressroom/releasesdetail.asp?* /pressroom/releasesdetail.asp
url /pressroom/newsdetail.asp?* /pressroom/newsdetail.asp
url /pressroom/news.asp?* /pressroom/news.asp
url /pressroom/releases.asp?* /pressroom/releases.asp
url /learning/imagepopup.asp?* /learning/imagepopup.asp
url /learning/museumartefacts.asp?* /learning/museumartefacts.asp
url /themuseum/galleries2.asp?* /themuseum/galleries2.asp
end rewrite