JohnnyDoomo Posted November 9, 2012 Share Posted November 9, 2012 I have a site that I'm trying to prevent people from linking directly to the download page. My urls look like this: http://domain.com/YrWlNpP2/ the "YrWlNpP2" part is dynamic and changing for different items, and the download page for the item is this: http://domain.com/YrWlNpP2/download/ I want it so that if somebody posts the: http://domain.com/YrWlNpP2/download/ link on an external site, that when the link is clicked, instead of downloading, it would instead simply open up: http://domain.com/YrWlNpP2/ or whatever dynamic string (YrWlNpP2) was in the original download link. However: http://domain.com/YrWlNpP2/download/ needs to work fine when it's accessed from my domain.com site. I know something like this is possible, as I have something similar working on an image site and protecting fullsize images, but have looked over that htaccess file, and can't see what parts I need to change to make it work in this format. Can somebody help me with what exactly I need to add to get this type of functionality? I'm not a programmer so if you can help me with exactly what needs to be added, I'd appreciate it. Thanks for any help on this subject! Quote Link to comment https://forums.phpfreaks.com/topic/270480-redirect-hotlinking-download-links-to-items-page/ Share on other sites More sharing options...
requinix Posted November 9, 2012 Share Posted November 9, 2012 HTTP_REFERER is what you'll want to use. Note that it's not perfect but will stop most people clicking on these hypothetical links. RewriteCond %{HTTP_REFERER} ^http://domain.com/ # RewriteRule blah blah blah Quote Link to comment https://forums.phpfreaks.com/topic/270480-redirect-hotlinking-download-links-to-items-page/#findComment-1391202 Share on other sites More sharing options...
JohnnyDoomo Posted November 9, 2012 Author Share Posted November 9, 2012 Don't want to simply prevent them from downloading the link and redirect them to the front page. It does me no good to not actually redirect them to the actual page that DOES contain a download link. That is why I need to be able to remove the /download/ part of the url if they try to access it from an external site. I've had sites do that to me, and it pisses the hell outta me that they don't make it at least take me to the proper download page if they don't want hotlinking. I'm hoping to fix that problem, so my site doesn't cause the same issue. Any other ideas? HTTP_REFERER is what you'll want to use. Note that it's not perfect but will stop most people clicking on these hypothetical links. RewriteCond %{HTTP_REFERER} ^http://domain.com/ # RewriteRule blah blah blah Quote Link to comment https://forums.phpfreaks.com/topic/270480-redirect-hotlinking-download-links-to-items-page/#findComment-1391383 Share on other sites More sharing options...
requinix Posted November 10, 2012 Share Posted November 10, 2012 Exactly what I said. I guess you understood the word "stop" to mean "prevent these people from reaching your site". The RewriteCond is a condition attached to a RewriteRule. When true then the Rule will execute and when not the Rule will not. So now your task is to write a RewriteRule that does what you want it to do. Quote Link to comment https://forums.phpfreaks.com/topic/270480-redirect-hotlinking-download-links-to-items-page/#findComment-1391413 Share on other sites More sharing options...
JohnnyDoomo Posted November 10, 2012 Author Share Posted November 10, 2012 Sorry, all I see is RewriteCond %{HTTP_REFERER} ^http://domain.com/ Unfortunantly, I don't have any expertise when it comes to finishing that. I'm looking for something that looks for urls that contain /download/ and if the referrer doesn't match my domain.com, then it removes the /download/ part of the url so that when people click those download links from an external site, they are taken to the page I want them to. How to do that though, is beyond me. Any chance of getting the full chunk of code for doing this? I'm not a programmer, so I have very little knowledge when it comes to writing out htaccess statements. Quote Link to comment https://forums.phpfreaks.com/topic/270480-redirect-hotlinking-download-links-to-items-page/#findComment-1391454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.