Author |
Message |
Darrell3831
Worker
![Worker Worker](modules/Forums/images/ranks/3stars.gif)
![](modules/Forums/images/avatars/Misc/linux.gif)
Joined: Feb 18, 2004
Posts: 244
|
Posted:
Tue Sep 21, 2004 7:28 pm |
|
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 |
_________________ http://www.psy-center.com |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Sep 21, 2004 7:40 pm |
|
At first glance your example looks okay. Did you try it? What happens? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Darrell3831
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Sep 21, 2004 7:52 pm |
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Sep 21, 2004 7:56 pm |
|
Just experiment with thiCode: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]
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Darrell3831
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Sep 21, 2004 8:31 pm |
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Sep 21, 2004 10:12 pm |
|
TryCode:RewriteRule .*\.([mpg|mpeg|zip|tar|exe|avi|mov|gif|jpe?g]+)$ http://www.psy-center.com/images/clipart/headbanger.gif [NC,R,L]
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Darrell3831
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Sep 21, 2004 10:40 pm |
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Sep 21, 2004 10:46 pm |
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Darrell3831
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Sep 21, 2004 11:00 pm |
|
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.
Only registered users can see links on this board! Get registered or login!
I just don't understand it from the instructions.
Thanks for your time!!
Darrell |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Darrell3831
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed Sep 22, 2004 6:15 am |
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|