Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Filter apache web get request using cgi-perl

by scorpio17 (Abbot)
on Jun 07, 2012 at 13:23 UTC ( #974939=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974939]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-07-22 10:46 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (453 votes). Check out past polls.