View Full Version : .HTACCESS Help!!!


sugarbyte
11-21-2004, 08:47 PM
I am trying to prevent people from direct linking my images and this is my .htaccess code:

ErrorDocument 404 http://hl2maps.ansiibomber.ch/sugarbyte/finalfantasy/404notfound.html
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?hl2maps.ansiibomber.ch.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?hl2maps.ansiibomber.ch.*$ [NC]
RewriteRule \.(gif|jpg)$ http://hl2maps.ansiibomber.ch/sugarbyte/finalfantasy/nodirectlinking2.gif [R,L]

I don't understand why the image replacement isn't working (i did a test of a page with an image with the whole pic url, as if i were direct linking) and it still doesn't work!! What could I be doing wrong? What am i doing wrong!? Thanks so much ^____^
ciaoo

Jared
11-22-2004, 12:15 AM
I don't think .htaccess is the best way to do this. PHP scripts would be the best, but your host might not support php.

"For goodness sakes, google it!" © Jared 2004

sitehelper
11-23-2004, 01:44 AM
I'm not entirely sure why it isn't working as I'm not 100% familiar with .htaccess, but here is code from my own site that I know works:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.YOURDOMAINNAME.com$ [NC]
RewriteRule .*\.(jpg|jpeg|png|bmp)$ http://www.stupidcelebrity.com/images/hotlinked.gif [R,NC]

sugarbyte
11-23-2004, 09:41 PM
so where do I enter this php code you just posted? And do i keep the $ sign after the .com? Thanks so much for your help ^^ :D

kittycat
11-23-2004, 09:51 PM
It's not a php code, just formatted like it... Copy it into your .htaccess file, change the domain and image paths and see if it works.

sitehelper
11-25-2004, 09:25 PM
yeah, sorry it's not php code, i just didn't know how else to post it so it wouldn't format into a smilie :) it goes in your htaccess file. Keep everything as is and just replace your domain name, and replace this part

"http://www.stupidcelebrity.com/images/hotlinked.gif"

with the url to another image you want to display to replace the others.

Or I think if you don't point it to a valid one it will just show up as an "x" for the hotlinkers if you don't want an image to show.