in reply to Filter apache web get request using cgi-perl

You should take a look at the Apache module MOD_REWRITE.

It will let you map a URL like this:

into something like this:

However, it might be a good idea to use some kind of id number, instead of the actual file name, in the URL. Then the script could use that id to do a database lookup, and get the path, filename, etc.

Using the actual filename may cause problems if it contains spaces, or other non-URI safe characters, for example.

The PDF files need to be in a directory NOT under the HTML document root (i.e., it needs to be impossible to access them by URL, else your system can be easily bypassed. Your script will need to read the requested PDF and then write it back out. Make sure to set the mime-type correctly in the html header (something like 'application/pdf'). This way if you have an index page listing all your files, when someone clicks on a link, the browser won't load a new page, but the pdf will open up in a new window. Note that the exact behavior may vary depending on which browser is being used, and what plugins have been installed, etc. Some people like for pdfs to open inside the browser, others prefer to launch a pdf reader on the side, while others may prefer to get the "save as" dialog and view it later. The mime type may help give you some control over this.