Forum Moderators: phranque

Message Too Old, No Replies

Redirect From Specific URL Possible?

Blogspot.com blogger stealing content and hotlinking images

         

old_expat

6:01 am on May 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm wondering if it is possible to redirect in such a manner that any request coming from a given URL will redirect to a page of my choosing.

The blog is on blogspot.com

Not only is the blogger in question hotlinking like crazy (20,000 requests so far this month), but is copying opening paragraphs verbatim and then linking to the full content.

I looked at Blogspot's DMCA requitrements and they are a bit difficult to understand. Quite convenient .. for blogspot.

ZydoSEO

12:42 pm on May 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like you want a rule such that if the referring URL is X then send them to some bogus page. Have you tried something along the lines of

RewriteCond %{HTTP_REFERER} <insert URL you are trying to trap>
RewriteRule (.*) http://www.example.com/bogus-page.htm

old_expat

1:50 am on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, the blogger is using a hyperlink to hotlink to images they don't have room to show on their pages. Normal hotlinking rewrites won't take care of that condition.

So I want to redirect those to my home page.

I'll give this a try, thanks.:)

old_expat

2:09 am on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Um .. didn't quite work and I should have guessed. I have a "no hotlinking images" rewrite and it's showing that. Is there a way to put a link into an image?

jdMorgan

5:03 am on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you can deny the request, or rewrite or redirect it to another image. <img src="xyz"> tags will not load another HTML page, they only work with images.

Of course, the replacement image could have your URL in it if you like... to be typed in by the viewer.

Jim

old_expat

6:55 am on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, my image with

For Best Information on "Destination"

visit MyReallyGreatSite.com

Is showing in 7 places on his blog.

I wondered why the hyperlink was also opening the hotlink.gif image .. now I know,

Thanks Zydo and Jim

Forgot to add .. the links to my content pages ala

http://www.example.com/mypage.php

apparently creates a loop (according to FF) .. so I'm wondering if that puts extra load on the server.

Right now the lines are commented out.

[edited by: jdMorgan at 4:10 pm (utc) on May 22, 2008]
[edit reason] example.com [/edit]

jdMorgan

4:13 pm on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> creates a loop...

Most likely because the code does not prevent a request for the replacement page/image from also being rewritten or redirected. This must be done explicitly in the code. Since I don't know what your code looks like, I can't be more specific.

Yes, that puts a big load on the server, the client, and the internet connection, and really should be fixed.

Jim

old_expat

8:19 am on May 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm using:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
RewriteRule .*\.(jpe?g¦gif¦bmp¦png)$ hotlink.gif [L]
#RewriteCond %{HTTP_REFERER} [hotlinker.blogspot.com...]
#RewriteRule (.*) [mysite.com...]

As you can see, the lines causing the loop are commented out

jdMorgan

3:21 pm on May 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Standing alone, the RewriteRule will rewrite hotlink.gif to itself, causing an internal rewrite loop. Use this method, patented by Stop-a-Loop Technology:

RewriteEngine on
#
[b]RewriteCond %{REQUEST_URI} !^/hotlink\.gif$[/b]
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*myspace\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*livejournal\.com/ [NC]
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ hotlink.gif [L]

I also cleaned up a few other inefficiencies in there.

For later readers: Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.

Jim

old_expat

7:50 am on May 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jim,

This line *apparently* causes a problem

RewriteCond %{REQUEST_URI} !^/hotlink\.gif$

The blogger is using 2 types of hyperlinks

1 - "Larger version of Image" >> [mysite.com...]

The blogger has also copied opening paragraphs from some of my content pages verbatim and then linked to the full content page on my site.

2 - "More information" >> [mysite.com...]

When a link is clicked for #2, the hotlink.gif image shows on my own "my-content-page.php" instead of the original images

jdMorgan

1:40 pm on May 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to flush your browser cache each time you do a test. For example, if you visit a site that hotlinks, then your browser displays the anti-hotlink image, which gets cached with the URL of the original image (because your code is doing an internal rewrite, the URL is unchanged).

Then, if you visit your own site, your page tries to load up the "good" image, but your browser renders the anti-hotlink image that it has just cached under that good-image's URL.

Bottom line is that when testing this kind of thing, you need to completely-flush your browser cache before loading any different Web page.

This can be overcome by using an external redirect instead of a internal rewrite, but this then "gives away" the fact that you've got an anti-hotlinking routine active on your site. Since no anti-hotlinking can be 100% effective, it's best to leave the hotlinker-webmaster (or forum/blog poster) scratching his head and wondering why his hotlinks fail most of the time -- Maybe he'll quit doing it.

Jim

old_expat

3:32 pm on May 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, I'll try it again.

Steptoe

8:36 am on Jun 11, 2008 (gmt 0)

10+ Year Member



I have been messing around blindly for about a week trying to get this to work
"Um .. didn't quite work and I should have guessed. I have a "no hotlinking images" rewrite and it's showing that. Is there a way to put a link into an image?"

But in the mean time I did do this
"Of course, the replacement image could have your URL in it if you like... to be typed in by the viewer."
<snip>

Then find I have wasted a lot of time
"No, you can deny the request, or rewrite or redirect it to another image. <img src="xyz"> tags will not load another HTML page, they only work with images."

But in my ignorance of coding im not fully convinced it cant be done?....
what if .htaccess had something like this
"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} .*jpg$.*gif$.*png$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !example\.net [NC]
RewriteCond %{HTTP_REFERER} !example\.sytes\.net [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /banhotlink.php?pic=$1

Then Something in the banhotlink.php to make it work..(this doesnt but along these lines? I have read where
<?php
header("Content-type: text/html");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache,
must-revalidate");
header("Cache-Control: post-check=0, pre-check=0",
false);
header("Pragma: no-cache");
// $pic = strip_tags( $_GET['pic'] );
// if ( ! $pic ) {
// die("No picture specified.");
// }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><?php echo($pic); ?></title>
<meta
http-equiv="Content-Type"
content="text/html; charset=iso-8859-1"
>
</head>
<body>
<p>
<a href="http://www.example.net"><strong><big></big></strong><b>Due to Hotlinking Abuse the Practice is Blocked</b><br>
<img src=/kikelogosm.gif width=315 height=61><br>
<strong><big></big></strong><b>You May Like to click Our Banner to Visit Us</b></a><br>
Admin: example.net
</p>
</body>
</html>

OR is it just impossible to put a url linked pic inside [img] [/img] tags on a website?

[edited by: jdMorgan at 4:15 pm (utc) on June 11, 2008]
[edit reason] No URLs, please. See Terms of Service and Charter [/edit]

jdMorgan

4:23 pm on Jun 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Again, you cannot serve an HTML page in response to a request for a picture -- It is "wrong" and the browser is not expecting HTML and cannot handle it. Your script should send only the raw contents of the replacement image file, and the cache-control and other headers.

Your mod_rewrite code looks like it was auto-generated for the most part, and could do with some clean-up and error corrections:


RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !example\.(sytes\.)?net [NC]
RewriteCond %{HTTP_REFERER} !\.google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule ^(.+\.(jpg¦gif¦png))$ /banhotlink.php?pic=$1 [NC,L]

I think you will find that code to be faster and work better.

Replace the broken pipe "¦" characters in the RewriteRule pattern with solid pipe characters before use; Posting on this forum modifies the pipe characters.

Jim

siteperf

12:03 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



The most fast way to block all domains except yours is:

SetEnvIf Referer ^http:// realref=1
SetEnvIf Referer ^http://(www\.)?domain.com goodref=1
SetEnvIf Referer ^http://(www\.)?other-domain.net goodref=1
<FilesMatch "\.(gif¦jpe?g¦png)$">
Order Deny,Allow
Deny from env=realref
Allow from env=goodref
</Files>

Using mod_rewrite is much slower way, while it allow to redirect this traffic (by mod_setenvif you can only block hotlink)
If your hotlinked data is in separate directory only - you can place this .htaccess there and skip <FilesMatch> and </FilesMatch> - it will be something faster.
If you don't want to pass empty referer then replace 'Order Deny,Allow' by 'Order Allow,Deny'