Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
Darrell3831
Worker
Worker



Joined: Feb 18, 2004
Posts: 244

PostPosted: Tue Sep 21, 2004 7:28 pm Reply with quote

Please excuse me if this would better fit in another folder.

I'm trying to understand how to use the .htaccess file to stop remote linking of images and to instead serve a different image in it's place.

Is this example accurate and complete?

Code:
RewriteEngine on 


RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://psy-center.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.psy-center.com/.*$ [NC]

RewriteRule \.(png|PNG|gif|GIF|jpg|JPG)$ http://www.psy-center.com/not_yet_created.gif [R,L]


I don't have any information except what I can find thru google. Do I need this above the RewriteEngine on?

Code:
AuthUserFile /dev/null

AuthGroupFile /dev/null


I did read the other post here that says how to protect downloads.

Code:
RewriteEngine on 

RewriteCond %{HTTP_REFERER} ^$ [OR]
RewriteCond %{HTTP_REFERER} !^http://(.*)fred-dresken.nl\.([com|net]+)/.*$ [NC]
RewriteRule .*\.([mpg|mpeg|zip|tar|exe|avi|mov|gif|jpe?g]+)$ - [NC,F]


I want the rule to instead substitute an image of my own creation.

Thanks for your time.

Darrell

_________________
[ Only registered users can see links on this board! Get registered or login! ] 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Sep 21, 2004 7:40 pm Reply with quote

At first glance your example looks okay. Did you try it? What happens?
 
View user's profile Send private message
Darrell3831







PostPosted: Tue Sep 21, 2004 7:52 pm Reply with quote

No Sir,

I havent tried it just yet but I'm about to. The reason I'm asking is because I have no experience with this stuff. I don't know what this:

AuthUserFile /dev/null
AuthGroupFile /dev/null

does, and rather or not I need it. It might partially work and I'd never know if I have something terribly wrong or not. lol

Darrell
 
Raven







PostPosted: Tue Sep 21, 2004 7:56 pm Reply with quote

Just experiment with thi
Code:
RewriteEngine on 


RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://psy-center.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.psy-center.com/.*$ [NC]

RewriteRule \.(png|PNG|gif|GIF|jpg|JPG)$ http://www.psy-center.com/not_yet_created.gif [R,L]
 
Darrell3831







PostPosted: Tue Sep 21, 2004 8:31 pm Reply with quote

The RewriteRule dosent seem to want to work for me.

I have tried yours with a .gif that does exist and also this:

Code:
RewriteRule \.(png|gif|jpg|jpeg|mpg|zip|tar|exe|avi|mov)$ http://www.psy-center.com/images/clipart/headbanger.gif [NC,R,L]


In both cases the remote site got an X'ed out image instead of the other image I wanted to substitute.

If I take gif out of the list then the substitution occurs. I don't understand how would you specify what filename extentions you want to substitute another file for???

Any other ideas for me to try?

Thanks,
Darrell
 
Raven







PostPosted: Tue Sep 21, 2004 10:12 pm Reply with quote

Try
Code:
RewriteRule .*\.([mpg|mpeg|zip|tar|exe|avi|mov|gif|jpe?g]+)$ http://www.psy-center.com/images/clipart/headbanger.gif [NC,R,L]
 
Darrell3831







PostPosted: Tue Sep 21, 2004 10:40 pm Reply with quote

That does block the image that I'm hot linking to from the romote site, but it does not do the substitution.

The same is true of this test as the one before. If I take gif out of the list then the substitution does occure.

Darrell
 
Raven







PostPosted: Tue Sep 21, 2004 10:46 pm Reply with quote

Well, the problem might be that you are redirecting to a GIF file at the same site you are blocking a GIF. To test the theory out, change the redirect to some simple .html file
 
Darrell3831







PostPosted: Tue Sep 21, 2004 11:00 pm Reply with quote

I changed this:

Code:
RewriteRule .*\.([mpg|mpeg|zip|tar|exe|avi|mov|gif|jpe?g]+)$ http://www.psy-center.com/images/clipart/headbanger.gif [NC,R,L]


to:

Code:
RewriteRule .*\.([mpg|mpeg|zip|tar|exe|avi|mov|gif|jpe?g]+)$ http://www.psy-center.com/test.html [NC,R,L]


On my other test domain the gif image that was hotlinked to was replaced by an x'ed out image.

I removed |gif from the list and this time still an x'ed out image no redirect no substitution..

*shrugs*

With these three lines:

Code:
RewriteCond %{HTTP_REFERER} !^$ 

RewriteCond %{HTTP_REFERER} !^http://psy-center.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.psy-center.com/.*$ [NC]


Isent the .* actually like saying any file name extention? If so, then I'd interpret it to mean were trying to say block any file name that has an extention.

I've read, read, and re-read the info on this.

http://httpd.apache.org/docs/mod/mod_rewrite.html

I just don't understand it from the instructions.

Thanks for your time!!

Darrell
 
Darrell3831







PostPosted: Wed Sep 22, 2004 6:15 am Reply with quote

Thanks for your time and suggestions!

Another person PM'ed me and told me "positively" that you cannot redirect to the same file extention that your blocking. As you suspected Raven.

So changing the RewriteRule to block all but jpeg and then substituting a jpeg did the trick.

Thanks,
Darrell
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©