There is such an address: userfile/file.pdf . It is necessary to redirect from it to pdfreader/read.php?file=file.pdf . How can I do that?
1 answer
Already answered a similar question. Click to find out how to give the file. Briefly: close the directory from access via .htaccess or put the file outside the web directory. Then we give the file to the user through the headers, as described by the link above. The code with the headers is placed in the script that will be accessed. And do not need redirects.
ps in order to avoid misunderstandings: "above the root of the site" or "outside the web directory" (as they say in the comments and answer) means this: for example, the site lies locally along the path D:\server\site.dev\www\ , where \www - web directory. That is, files can be placed at a higher level, for example, along the path D:\server\site.dev\files\
- And if I have a website on a hosting, then which directory should I choose? - bellator001
- In most cases, not printsitsialno. If you close a directory by putting .htaccess there with the closing directive deny from all, then you can also in the web directory. Or you can in the home directory. Often the directory to which the site root is tied looks like / home / public_html or / srv / www, and you place your folder with the files in / home or / srv. But for good it is if there is nothing more there, except for your site. I would recommend the first option with htaccess for clarity. - white-imp
- Suppose I created this folder as / home / username / files and put there .htaccess parameters with deny from all, then through the pdf.js library, how do I make the path to it? So that pdf.js can read the file found there? - bellator001
- Following the example of pdf.js, a completely non-hidden file is issued. It can be picked up through pdf.js and through the address bar. Here is the mozilla.imtqy.com/pdf.js/web/viewer.html page that opens this mozilla.imtqy.com/pdf.js/web/compressed.tracemonkey-pldi-09.pdf file. There is nothing hiding. 1) Why do you need to redirect? 2) If you started talking about pdf.js, then the redirection question is not specific enough and there are no references to pdf.js in the description of the question. 3) Moreover, the file can even be downloaded via the page with pdf.js! This makes a more rhetorical question in paragraph 1. - white-imp
- I redid the pdf.js. in my case, download and copy and print is prohibited. I am the source file of the viewer.js file), so there is no direct path there. And the direct path is also izenil in the address bar you can see only viewer.php? Hesh = 12123kj124hg124 like that)) - bellator001
userfile/file.pdfreally exist? - Visman