Jump to content

Redirect Hotlinking Download Links To Items Page?


JohnnyDoomo

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.