1

After googling I didn't find answer to my question. So, question. I have site with http://www.emathhelp.net Inside it there is folder with pdf files.

I want to restrict direct access to pdf files, so http://www.emathhelp.net/1/3192849.pdf will return error, but a page with code <object data="pdf/1/3192849.pdf"></object> will correctly fetch pdf.

One of the attempts was to redirect all urls that end with .pdf to php script which then will find the page where pdf is embedded and redirect there. It was done, however inside <object></object> there is black screen, because I guess data="pdf/1/3192849.pdf" is rewritten also an thus infinite loop is created.

Can you help me? Maybe there are some solutions through .htaccess, maybe I don't need to use <object>. Please, write your suggestions.


Take it out of the web root folder. However, when it is supposed to be shown, use PHP to copy it to a temp location in your web root folder and display it to the user who is meant to see it. Keep a record of the temp file in a database, so that it is removed after say 1-2hrs.

Links:

4

1 回答 1

1

将其从 Web 根文件夹中取出。但是,当它应该显示时,使用 PHP 将其复制到您的 Web 根文件夹中的临时位置,并将其显示给打算查看它的用户。在数据库中记录临时文件,以便在 1-2 小时后将其删除。

链接:

于 2012-04-26T23:18:51.413 回答