Html – Link to a file in a higher level folder

filehrefhtml

I'm having troubles serving a document which is in a higher level than my root folder.

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

In the browser the above gets interpreted as:

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

I cannot see the browser going up in the folders and then the answer I get is:

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

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

Any help will be appreciated.

Best Answer

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

A solution would be to put that .docx inside of your document root (where your index.html is in).

You can however let PHP serve the file using the readfile function. But don't forget that www-data would need to have access to the file you're serving.