Hiding or obfuscating URL paths to files

I allow users to upload .jpg, .pdf.doc.xls files to their web server under their own account, then they can later click on the file name to view the document in a browser or in case. doc.xls, they download it at the prompt of the default browser.

I want to hide the / obfuscate url so that they don’t know the exact path to access the file, hoping to protect the files from other accounts / users.

I am using php, apache

Here's an example of a path:

http://dev.site.com/administrator/account_files/1/documents/property_docs/1_68_1295980609myfile.pdf

How can I hide the url for example:

http://dev.site.com/1_68_1295980609myfile.pdf

The main goal is to remove the link to "administrator / account_files / ...."

Is there something with apache mod_rewrite that I could do? I read a few other posts where people used php readfile () and used a different page, but I am wondering if I will have performance problems with this.

Thanks for your advice.

+3
source share
3 answers

You need to create a table to read and store paths. For example, see how sites like http://bit.ly ; essentially they assign a unique string to the url and what you want to do.

There are several PHP scripts that can shorten the URLs for you and thus mask paths, just do a google search .

0
source

, , , readfile. . , PHP script.

, - , .htaccess. readfile , .

0

You must force PHP to load this file:

<?php
$file = 'path/to/your/file.zip';
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/zip"); // change to a specific mime type
header("Content-Transfer-Encoding: binary");
0
source

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


All Articles