Forum Moderators: phranque
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.
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]
Jim