homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

htaccess causing a 500 (internal config) error
htaccess config error

 10:35 pm on Sep 21, 2006 (gmt 0)

I have successfully run htaccess up until this last week. I have Apache 2.0.59 installed and have had it for some time.

I can not figure out how to find what has changed.
here is my htaccess contents...

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com(/)?.*$ [NC OR]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?quux.com(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp)$ http://www.example.com/NoHotlinks/NoHotlinks.gif [R,NC]

Right now I have htaccess disabled so my page can be online.

[edited by: jdMorgan at 10:41 pm (utc) on Sep. 21, 2006]
[edit reason] Examplified. [/edit]



 10:43 pm on Sep 21, 2006 (gmt 0)

What do you see in your server error log file?



 12:22 am on Sep 22, 2006 (gmt 0)

[NC OR] should have a comma seperating NC and OR, not a space.

However what you've got there is a condition which is triggered if the referrer is not example.com *or* not quux.com. Since the referrer can't be both, one of these conditions will always be true, so the rule will trigger on all image hits where there's a referrer. You should remove the OR so that it's only true if the referrer is neither domain.


 12:29 am on Sep 22, 2006 (gmt 0)

Well, since the cat's out of the bag, the whole thing could do with a rewrite:

RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?quux\.com [NC]
RewriteRule \.(gif¦jpe?g¦bmp)$ http://www.example.com/NoHotlinks/NoHotlinks.gif [R,NC]

Replace all broken pipe "¦" characters above with solid pipe characters from your keyboard before use; Posting on this forum modifies those pipe characters.

The first RewriteCond is not needed unless your site has a dedicated (non-shared) IP address. It is unnecessary on most name-based virtual servers (shared hosting), which are inaccessible via HTTP/1.0.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved