hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Hotlinking Help!
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Hotlinking Help!

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-24-2004, 10:36 PM
tacoX tacoX is offline
Disabled
 
Join Date: Aug 2003
Posts: 77

Hotlinking Help!


Well, I have a problem. I run a free image hosting service thats growing fast (http://www.imghst.com). I delete users that are unactive after 30 days, along with the images they upload.

Now, when I delete the images it shows red x's. Instead of the red x's, id like an add for ImgHst (to promote our free services). Now, I dont want to ban ALL hotlinking (users are allowed to link their free images). But when I delete their images, I want an add.

Here is an example site that uses it: http://www.IOWNJOO.com. (you can link to their images, but if you attempt to link to an image not located on their server it shows an add). I know this uses .htaccess and POSSIBLY mod_rewrite.

Thanks to everyone in advance. I will be extremly grateful.

Reply With Quote


Sponsored Links
  #2  
Old 07-25-2004, 04:11 AM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100

__________________
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my blog
Signal > Noise

Reply With Quote
  #3  
Old 07-25-2004, 06:58 PM
GHDpro GHDpro is offline
Junior Guru
 
Join Date: Nov 2000
Location: Holland
Posts: 246
I think the easiest way of setting this up would be custom 404 (and 403)
error pages. I'm not 100% positive if it's possible to return images instead
of HTML files, but I'm pretty sure it should work.

http://httpd.apache.org/docs/mod/cor...#errordocument

This method is also guaranteed not to interfere with existing images.

__________________
.

Reply With Quote
Sponsored Links
  #4  
Old 07-26-2004, 02:03 PM
tacoX tacoX is offline
Disabled
 
Join Date: Aug 2003
Posts: 77
I know how to make custom 404 error pages, but I really would like it to replace images.

Reply With Quote
  #5  
Old 07-27-2004, 08:44 AM
GHDpro GHDpro is offline
Junior Guru
 
Join Date: Nov 2000
Location: Holland
Posts: 246
Well, like I said -- don't use pages as your 404 Error Documents,
use the image you want to use as advertisement as 404 Error Document.

Like:
Code:
ErrorDocument 404 /images/advertisment.jpg
I haven't tested this yet, but in theory this should mean Apache returns
the image when a 404 is encountered. And that would mean that those
red X's (which are 404's) now return your advertisment image instead.

---
Before I wrote the stuff above, I hadn't tested this yet, but since I need
it as well for my own service as well, I've now tested it -- works fine:

http://s01.imagehost.org/This_Link_I...Does_Not_Exist

Feel free to make up your own URLs to append to the domain name to test it futher.

__________________
.

Reply With Quote
  #6  
Old 07-27-2004, 04:37 PM
tacoX tacoX is offline
Disabled
 
Join Date: Aug 2003
Posts: 77
Wow, it does work! Do I just make a .htaccess with just that in there?

Reply With Quote
  #7  
Old 07-28-2004, 02:31 AM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,100
This would also mean that anyone that manages to type in a wrong non-image URL will get your advertisement ... not a smart idea.

__________________
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my blog
Signal > Noise

Reply With Quote
  #8  
Old 07-28-2004, 05:35 PM
GHDpro GHDpro is offline
Junior Guru
 
Join Date: Nov 2000
Location: Holland
Posts: 246
Not sure what you mean about "not smart"...

In any case if all images are stored in one particular folder, you
can just put the .htaccess file in there only, which makes the
ErrorDocument rather "local".

Alternatively, and this would get complicated a bit, you could redirect
the ErrorDocument to a PHP script. You can then have that PHP script
analyze what kind of URL is being requested (using the $_SERVER["REQUEST_URI"]
variable I think), check if it's an image (check for extension) and then
return the advertisement (using "fpassthru" and "header") or if it does not
seem to be an image, display an error OR redirect to the main page, whatever
you want.

__________________
.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
NetDNA Gives Site Managers Granular Control over Content with New EdgeRules Service Web Hosting News 2013-01-22 13:35:47


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?