Web Hosting Talk







View Full Version : Looking for a way to BLOCK a web page when it comes from a particular location


wf19
08-21-2002, 12:03 AM
There's someone out there who has a web page of mine on their public profile. I don't want to be associated with this individual.

Using a service like Sitemeter (http://www.sitemeter.com) it's possible to track where your hits are coming from.

Is it possible that to not only detect where a hit is coming from, but somehow block, or redirect (perhaps to another page that states "go away") when it comes from a specific location?

For example, if somone puts a link to my page on their profile at:
http://profiles.yahoo.com/(yahoo_ID_here)

Is it possible to reject or redirect the page by sensing where it comes from.

If previous page = x
then redirect to y
else, go to z

Is it possible to foward the page to another location if and only if it comes from a specific location or site?

JTY
08-21-2002, 12:09 AM
Yes, you can do this. By using a script. Or perhaps Apache mod_rewrite could do this.

wf19
08-21-2002, 12:13 AM
Originally posted by JTY
Yes, you can do this. By using a script. Or perhaps Apache mod_rewrite could do this. Could you please explain how I can do this? Where is this script/code? I'm very good with HTML, but I don't know what Apache mod_rewrite is.

Thanks.

prime
08-21-2002, 12:17 AM
I can't go into the details, but someone else will probably be able to...

Wouldn't it be easier and faster, since he knows where the traffic is coming from, to use a .htaccess file and the HTTP_REFERER var?

wf19
08-21-2002, 12:21 AM
Originally posted by prime
Wouldn't it be easier and faster, since he knows where the traffic is coming from, to use a .htaccess file and the HTTP_REFERER var? You're speaking in greek to me.

Is it possible to explain this in layman terms?

dreamrae.com
08-21-2002, 12:55 AM
php, perl, asp, jsp, c, .htaccess, firewall, i dunno 403 their asses

wf19
08-21-2002, 12:56 AM
Would someone please tell me how to do this?

wf19
08-21-2002, 01:55 AM
I posted this on several forums. Here, Emaildiscussions.com, Sitepoint...

and the winner is.....

CRAIGSLIST!!!!

http://forums.craigslist.org/?ID=2275667

Someone on Craigslist did this for me ;)

Website Rob
08-21-2002, 02:02 AM
Have a look at this thread:

http://www.webhostingtalk.com/showthread.php?threadid=47529

if applicable, just post your questions there -- helps to keep it together. :)

The above method uses .htaccess (tops in my book) but there a way to restrict access by using a JS script, that follows your method:

If previous page = x
then redirect to y
else, go to z

but, being JS, would require the code to be on every page -- not good. Using .htaccess you can apply restricting to every page on your Web site, with only a few lines of code in an .htaccess file.

wf19
08-21-2002, 02:21 AM
Thanks, it appears the Craigslist method:

http://forums.craigslist.org/?ID=2275667

is working just fine for my needs. ;)

combs
08-21-2002, 03:54 AM
anybody have any examples of this modrewrite?
I know some guy hotlinking my images.. leaeching of my bandwdith damnit.

wf19
08-21-2002, 04:11 AM
Originally posted by combs
anybody have any examples of this modrewrite?
I know some guy hotlinking my images.. leaeching of my bandwdith damnit. That's tricky. You can't put code into a .jpg file

Website Rob
08-21-2002, 04:25 AM
Weelll, if your hoster provides Cpanel (like some do ;)) then you have Anti-leech built in. If not, you can go the route of downloading a free/pay-for script (lots around at the script sites; look under: anti-leech) or using the .htaccess method with a RewritCond directive.

If you are not familiar with Apache directives, you are best to get in touch with your Hoster to see if/how they have Rewrite rules working.

goldenplanet
08-21-2002, 05:35 AM
Put this in a .htaccess-file and the bugger is history:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain.com/.*$ [NC]
RewriteRule .*\.gif$ - [F,L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain.com/.*$ [NC]
RewriteRule .*\.jpg$ - [F,L]

This will allow gifs and jpgs to be served if the HTTP_REFERER is your domain - and only you. Remember to add additional lines if you have parked domains and/or other subdomains than www! ;)

fog
08-21-2002, 10:26 AM
anybody have any examples of this modrewrite?
I know some guy hotlinking my images.. leaeching of my bandwdith damnit.
Another less technical image (that I've actually seen done before) is to simply copy the image to another name, and change it on your site -- so if everyone was accessing, say, image.jpg, you would change your site to use image2.jpg. Then replace image.jpg with a blurry 1600x1200 picture of a tree or something... If the leechers are using it inline on their page, their site will look totally screwed up, and they'll quickly take the image down. (Be prepared for the site owner to be piping mad, but it's his own fault :rolleyes: )

The .htaccess file probably works a lot better, but replacing the image is a lot more fun. :D

prime
08-21-2002, 10:43 AM
Originally posted by Website Rob
Have a look at this thread:

http://www.webhostingtalk.com/showthread.php?threadid=47529

if applicable, just post your questions there -- helps to keep it together. :)

The above method uses .htaccess (tops in my book) but there a way to restrict access by using a JS script, that follows your method:


That's exactly what I had in mind. But I haven't played around enough with htaccess to be able to give an exact answer.

I too felt that it would be more effecient than JS for a couple of reasons, but if he's happy with it, then so be it.