I've been struggling to get this .htaccess working. The aim is to disallow all user agents besides my app. The app sends a GET request with a user agent of lets say 'AcmeUpdater'.

Whenever I try to navigate to any file in the folder, I get a 500 - Internal Server Error. Here are the rules I'm using:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} !^KMUpdaterClient*
RewriteRule .* - [F,L]

I have updated the .htaccess file as suggested in the answer by Nick, and restarted Apache. After trying a couple of different things, it seems that just the presence of a .htaccess is causing the 500 error. I'm getting nothing in the error logs.

The .htaccess file at the document root looks like the following:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

So I realised that the error logs were in chronological order rather than the reverse chronological I expected (Oops!).

The error I'm getting is: </IfModule> without matching <IfModule> section. I removed the </IfModule> and still I get that error. Ideas?

  • Comment line by line (and restart/reload apache each time) and you will see what is wrong.
    – j0k
    Commented Aug 28, 2012 at 10:15

1 Answer 1


Finally realised what the problem was when, after deleting the tag in both files, the error "Invalid command '\xef\xbb\xbf


Moral of the story: Always check your encoding* and hex dump of your files when you get weird issues.

*On Notepad++ you can use the Encoding -> Encode in UTF-8 without BOM option to remove it


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.