If I've understood you correctly, would it be worth considering using the output of the cgi script to create an html file in the same directory as the original file and then redirect to it. I'm thinking this might help with the links problem.
In reply to Re: Scripts to recursively reading in HTML files
by wfsp
in thread Scripts to recursively reading in HTML files
by mwhiting
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |