Forum Moderators: phranque

Message Too Old, No Replies

.htaccess

first timer, dumb questions

         

molecularr

4:06 am on Oct 26, 2004 (gmt 0)

10+ Year Member



Hi.

This is my first time tinkering with an .htaccess file, so please excuse what is possibly a dumb question.

I'm trying to prevent hotlinking, so I've tried a couple of different examples (some from other threads on here) but the result of any of them was the same: I get a 'Error:500 internal server error' whenever I try to load any pages on the site.

Here's an example of what I'm trying to make work:


RewriteEngine On
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com/ [NC
RewriteCond %{HTTP_REFERER}!^$
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ images/nohotlink.jpg [L]

Many thanks.

molecularr

4:07 am on Oct 26, 2004 (gmt 0)

10+ Year Member



Sorry, I meant to conclude that with something more like "If there's something obvious I'm missing, please let me know"

As it is it sounds like a demand. Anyway, thanks in advance for any suggestions.

jdMorgan

4:23 am on Oct 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first thing you want to do when you get a 500-Server Error is to check your server error log file.
If you don't have access to it, then consider changing hosts; Lack of access to basic services is going to hinder the development of your site.

If you check your error log, it's possible (among several other possibilities) that you'll see a message that says, "Options followsymlinks or symlinksifownermatch is off which implies that RewriteRule directive is forbidden...", which means you need to enable FollowSymLinks on your server.

With that addition, plus an efficiency tweak and a disambiguation tweak, this might work better:


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} [b].[/b]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC]
RewriteRule \.(jpe?g¦gif¦bmp¦png)$ [b]/[/b]images/nohotlink.jpg [L]

If not, then you must get access to your error log in order to find out what the problem is.

Jim