How can I prevent hotlinking of my zip file?My host doesn’t allow .htaccess file to use. Is there any alternative to prevent hotlinking of my zip file? |
| Posted by: RaxitR; Post:1; Comments:1; Date of Join: Dec 20, 2008, 16:53 Post date: Dec 20, 2008, 16:56 |
| New topicReplyContactReport |
Re: How can I prevent hotlinking of my zip file?Create a text file with proper htaccess code and upload it to your web server. Now rename that file as .htaccess. That will work. |
| Posted by: anindita; Post:0; Comments:3; Date of Join: Nov 14, 2008, 07:51 Post date: Dec 20, 2008, 17:13 |
| ContactReport |
Re: How can I prevent hotlinking of my zip file?Sorry, I have already tried it. But it doesn’t let me rename to .htaccess. |
| Posted by: RaxitR; Post:1; Comments:1; Date of Join: Dec 20, 2008, 16:53 Post date: Dec 20, 2008, 17:19 |
| ContactReport |
Re: How can I prevent hotlinking of my zip file?Keep your zip file at a secure location, say at the parent folder of your public_html folder such that viewers can’t access that file directly. If that folder not available to you use a long filename say abcdef.zip and keep it in a folder say download. Put a blank index.html file at that folder to prevent file listing.At the top of your download page, say downloadcenter.php writes the following code: Code <?php session_start(); $_SESSION['download'] = 'download_ok'; ?>Create another file say downloadnow.php with the following codes: Code <?php
session_start();
if ($_SESSION['download']==='download_ok'){
// The name by which the user prompted to save.
$save_as='myfile.zip';
// Actual path where you keep your zip file.
$actual_path='download/abcdef.php';
// In case of direct linking where the user will be redirected.
$redirect='http://yourdomain.com/downloadcenter.php';
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=$save_as');
readfile($actual_path);
}
else {
header('Location: $redirect');}
?>Now put a link to open the file downloadnow.php at the page downloadcenter.php.
----------------------------------------------------------- |
| Posted by: admin; Post:34; Comments:116; Date of Join: Nov 05, 2008, 08:04 Post date: Dec 24, 2008, 05:33 |
| ContactReport |