Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

We have a landing page which is used only for running an ad campaign. There is a website that has found this link somehow and is linking to it. I've been told by marketing they don't want that website linking to the landing page. How can I prevent a specific website from linking to our domain? I don't want to block all websites from linking to it, just this specific one. Is there solution something to do with .htaccess? If so, please provide an example of doing this or a link to example because I've been unable to find one.

share|improve this question
Marketing doesn't want it linked to, because it's part of an ad campaign as I stated. Which means it will have a special call to action and contain information out of context and will confuse those that visiting the website that didn't come there from the ad. This is not censorship anymore than preventing people from knowing what a temporary phone number is for tracking so they don't think it's the MAIN phone number. Too bad some people are less on being helpful and get on their high horse about things they don't understand like how the real world functions for the greater good. – Edward Mar 17 at 4:58
1  
I see no comments or answers here with people getting on their high horses. You asked a question, and people are providing you with answers. – nhinkle Mar 17 at 6:32
@nhinkle That's because you didn't read all the comments or you didn't understand them. – Edward Mar 17 at 7:04
You're welcome to think whatever you want, but I'll give you a tip from experience: the nicer you are to people, the more likely it is that they'll try to help you. When you start throwing around accusations, it doesn't earn you any goodwill. – nhinkle Mar 17 at 7:31
I'll give you a tip as well. Spend a little more time away from the computer and around people because you have very rude manners. If you didn't have anything positive and helpful to contribute to the forum then simply don't reply. You commented rudely without even reading what was commented on such as " I would hope you loose" That's all there is to it, don't feed the trolls here which is what you did. Enough said. Peace. – Edward Mar 17 at 7:32

migrated from superuser.com Mar 17 at 6:33

2 Answers

up vote 0 down vote accepted

http://www.javascriptkit.com/howto/htaccess10.shtml

In the webmaster community, "hot linking" is a curse phrase. Also known as "bandwidth stealing" by the angry site owner, it refers to linking directly to non-html objects not on one own's server, such as images, .js files etc. The victim's server in this case is robbed of bandwidth (and in turn money) as the violator enjoys showing content without having to pay for its deliverance. The most common practice of hot linking pertains to another site's images.

Using .htaccess, you can disallow hot linking on your server, so those attempting to link to an image or CSS file on your site, for example, is either blocked (failed request, such as a broken image) or served a different content (ie: an image of an angry man) . Note that mod_rewrite needs to be enabled on your server in order for this aspect of .htaccess to work. Inquire your web host regarding this.

With all the pieces in place, here's how to disable hot linking of certain file types on your site, in the case below, images, JavaScript (js) and CSS (css) files on your site. Simply add the below code to your .htaccess file, and upload the file either to your root directory, or a particular subdirectory to localize the effect to just one section of your site:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|js|css)$ - [F]

Be sure to replace "mydomain.com" with your own. The above code creates a failed request when hot linking of the specified file types occurs. In the case of images, a broken image is shown instead. Serving alternate content when hot linking is detected

You can set up your .htaccess file to actually serve up different content when hot linking occurs. This is more commonly done with images, such as serving up an Angry Man image in place of the hot linked one. The code for this is:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/angryman.gif [R,L]
share|improve this answer
4  
This won't even work for this situation. This is for preventing hotlinking, not for preventing links to the full page from another site. – nhinkle Mar 17 at 6:31
This was the most helpful and provided a very useful link. – Edward Mar 17 at 7:38

You can't stop a site linking to you with technical measures, but you can identify requests which have come from that site/url and block these in .htaccess -

RewriteEngine on
RewriteCond%{HTTP_REFERER} ^http://www\.site\.com [NC]
RewriteRule index.html   http://www.go-away.com/goaway.html [R]

The above rules will probably need some tweeking, but the idea is to match the REFERER (yes, that spelling is correct) - in this case where the referer starts with http://www.site.com - and then if they land on index.html redirect them to the url goaway.html)

If you REALLY want to attempt to stop them from linking to you, I'd suggest finding out who they are and getting a lawyer to write a letter. Then follow it up with legal action if you can find grounds to.

share|improve this answer
1  
I wouldn't go as far to say that "i hope you loose". Sites that get a lot of traffic can cost a lot of money in bandwidth as well as skewed perspectives of a cause. A locked door keeps a honest man honest. – kobaltz Mar 17 at 4:34
3  
@kobaltz - I respectfully disagree. Trying to prevent someone from linking to your site is akin to saying to them they are not allowed to say certain things (because all a link is doing is saying look over there). Preventing someone from creating this link is censorship - something which is not compatible with a healthy Internet. [Hence why I suggest a technical measure to distance yourself from the site or drop the traffic from people with that referer ] I also point out the request is being made by a marketing drone - its not a "Help, I'm being DOS'd" post. – davidgo Mar 17 at 4:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.