Rewriting links for a proxy

This popup dictionary acts as a proxy, fetching a web page and then adding popup dictionary headings. Although the page uses HTML::ResolveLink to rewrite links inside the page, some dynamically generated parts of the page still request images without absolute URLs. In order to fix this problem, I added a line to .htaccess of the form

RewriteCond %{HTTP_REFERER} cgi/popupdic\.cgi\?url=(http://[^/]+/)
RewriteRule (.*) %1/$1 [R=301]
This permanently redirects (the function of the R=301) a request like /image/example.png with a referrer of the form http://www.sljfaq.org/cgi/popupdic.cgi?url=http://www.example.com to the URL http://www.example.com/image/example.png.
Copyright © Ben Bullock 2009-2012. All rights reserved. For comments, questions, and corrections, please email Ben Bullock (ben.bullock@lemoda.net) / Privacy / Disclaimer