Link to a file in a higher level folder

I'm having problems servicing a document that is at a higher level than my root folder.

<a href='../../home/folder/document.docx'>Proposal</a> 

In the browser, the above is interpreted as:

 http://localhost/home/folder/document.docx 

I don’t see how the browser works in folders, and then I get:

 Not Found The requested URL /home/folder/document.docx was not found on this server. 

I tried in Firefox and Chrome, it happens. I am using Apache Web Server on a Linux machine.

Any help would be appreciated.

+4
source share
1 answer

You cannot redirect your visitors to a file outside of your document root (where you have index.html). People cannot see files higher than where http://localhost/ ends.

The solution is to put this .docx inside your document root (where your index.html is located).

However, you can pass the PHP file using the readfile function. But do not forget that WWW data must have access to the file that you are serving.

+6
source

Source: https://habr.com/ru/post/1415303/


All Articles