View Full Version : .htaccess Trouble


DeaG
09-12-2006, 02:48 AM
I am trying to use the .htaccess to prevent hotlinking. I asked my hoster about the Apache and and the mod rewrite - they said yes, we support it.

Then I tried to use this .htaccess:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?deapixeljunk.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?deapixeljunk.com.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.deapixeljunk.com/youarestupid.gif [R,L]

As soon as I uploaded it, the .htaccess disapeared... The hot-linked test images were not replaced with that really simpatic image and when I tried to access my site, all I got was this error page:

"Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@deapixeljunk.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at www.deapixeljunk.com Port 80"

I replaced the .htaccess with a blank one and everything went back to normal... But I really want this hot-linking prevention...

Licorne
09-14-2006, 05:56 AM
Try this code:

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