Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-07-2003, 11:36 PM   PM User | #1
blackhat
New to the CF scene

 
Join Date: Feb 2003
Location: Norway
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
blackhat is an unknown quantity at this point
htaccess - Hot linking

I read the tutorial at javascriptkit.com on how to prevent hot linking, I used this code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/nasty.gif [R,L]

but I can't even see the pictures on my own server when using this code, so what do I need to add here to make it work?

Thanks in advance
Blackhat
blackhat is offline   Reply With Quote
Old 02-21-2003, 07:16 AM   PM User | #2
MLReynolds
New to the CF scene

 
Join Date: Feb 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
MLReynolds is an unknown quantity at this point
Did you replace "mydomain.com" with your own domain name?

ie, "YourDomainName.com"

Also, I had to put in two lines, since I can be accessed with or without the "www."

Mine reads;
RewriteCond %{HTTP_REFERER} !^http://?michaelsplace.us/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?michaelsplace.us/.*$ [NC]

(although that's what I was told. I didn't try with just one line)
__________________
MLReynolds
MLReynolds is offline   Reply With Quote
Old 02-21-2003, 05:44 PM   PM User | #3
Feyd
Regular Coder


 
Feyd's Avatar
 
Join Date: May 2002
Location: Los Angeles, CA Maxim: Subvert Society
Posts: 404
Thanks: 0
Thanked 0 Times in 0 Posts
Feyd is an unknown quantity at this point
You don't need to use two different lines to specify www and non-www, MLR...try this instead:

Code:
RewriteCond %{HTTP_REFERER} !^http://([a-z0-9-]+\.)*yourdomain.*$ [NC]
That will pretty much match everything you need it to (www vs. non-www, virtual domains, different domain identifiers, etc.)
__________________
Moderator, Perl/CGI Forum
shadowstorm.net - subvert society
Feyd is offline   Reply With Quote
Old 02-21-2003, 06:51 PM   PM User | #4
MLReynolds
New to the CF scene

 
Join Date: Feb 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
MLReynolds is an unknown quantity at this point
Thank you for the tip. I still have a problem with Google's cache files displaying properly. Text only displays. Not images or formatting.

Any Idea?
__________________
MLReynolds
MLReynolds is offline   Reply With Quote
Old 05-16-2003, 07:00 AM   PM User | #5
dragon
New Coder

 
dragon's Avatar
 
Join Date: May 2003
Location: Florida
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
dragon is an unknown quantity at this point
On a similar note, I'm trying to set up htaccess to prevent hotlinking but allow images to be viewed from multiple locations, my primary website and a forum hosted by someone else. The forum is at http://users.boardnation.com/~dragon76n/ so here's what I used:
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?dragonshobbies.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(users\.)?boardnation.com/~dragon76n/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.dragonshobbies.com/dhminilogo.gif [R,L]
The problem was that it would still display my dhminilogo.gif on my forum.

Should I write out the address completely, instead of having users\. in parenthisis? (I just thought of this so I haven't had a chance to test it yet.) Or what should I do?

UPDATE:

Code:
RewriteCond %{HTTP_REFERER} !^http://users.boardnation.com/~dragon76n/.*$ [NC]
This code did work to allow my forum to get the images. I ended up putting it into the images folder though, instead of in the root folder.
__________________
http://www.dragonshobbies.com

Last edited by dragon; 05-19-2003 at 07:06 AM..
dragon is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:34 PM.


Advertisement
Log in to turn off these ads.