Reputation: 327
main link is: yourname.com/movie/film.mkv
download link for users: yourname.com/2012/Esx123Sxzz96/film/
How to switch link 2 to link 1 without users seeing the main link and it appearing in a download manager?
Upvotes: 1
Views: 1595
Reputation: 7773
First, use a .htaccess
to prevent direct access to the /movie/ folder if you want to protect your site from having users accessing directly the data.
Then, it's a matter of passing the file through php, sending the appropriate header
first, see this thread for more information.
If your movies are large files, consider alternate methods to send the file, such as x-sendfile
which I never used on my own, see this answer for more information.
Edit: if you don't have user authentication to do, stats tracking, download limiting, etc... and simply want to rewrite the path you could use an .htaccess
to rewrite
the path (though with the kind of 2nd path you provide, it seems like you need logic to extract the desired path). If you don't care that the user knows the "secret path" after clicking the link, you could simply use a header('Location: yourname.com/movie/film.mkv");
- this would allow the user to set a bookmark to your file and never have to go through your yourname.com/2012/Esx123Sxzz96/film/
path again.
Re-Edit Apparently, the real question is how to create a whole system where media can be stored and then accessed through a "different" path, hiding the source.
What I would do is build a list, or database, for every media you want to store. When adding an item to the list, give it a unique ID. To keep things simple, lets start with 0 and increment by one for each file. You could store more information from your media in the list/database, such as the length of each movie, the filesize, etc...
Then, when you want to list these files to the user, you simply hash
the id, you can use something like this, which will create a string such as U6dc
... can now build links using: <a href="mysite/files/$hashedValue">Link for $filename</a>
.
Intercept the calls to mysite/files/
using a .htaccess
and redirect it to say files.php
which will be responsible to translate the parameter U6dc
into an ID in your list. Once you have this ID, it's easy to find the media on your drive and send it to the user, maybe using x-sendfile
, up to you.
Upvotes: 1