Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this, and only this, in a .htaccess file inside my downloads folder:

<FilesMatch "\.(exe)$">
  AuthType Basic
  AuthName "Downloads"
  AuthUserFile path/to/.htpasswd
  Require valid-user

Once I click the link to download a href="fileName.exe">FileName</a>, I'm getting a 500 server error.

If I leave out the <FilesMatch>-part; The protection part is working, I guess, since I get the login box. But once I get into the protected area, the 500 server error occurs.

What am I doing wrong here?

My intention was to protect only a single .exe file to prevent downloaded by anyone.

Is there any easier or more correct way of doing this?

share|improve this question
up vote -1 down vote accepted

If you didn't make a typo when asking firs line should be <FilesMatch ~ "\.(exe)$"> All info you can get from

share|improve this answer
Hey, didn't make a typo, so there might be a problem with the first line. Not on that computer until tomorow, so I'll look into it then... – ThomasK Jul 5 '12 at 19:25
Please point people at the current documentation - or at least to a version that's not 10 years old. – adaptr Jul 6 '12 at 8:34

If you want to protect a single file, why are you using FilesMatch to begin with ?

Of course, all Directory-level directives are prohibited inside htaccess files; your error log will tell you exactly what you did wrong.

Just use your httpd.conf with a straight section.

share|improve this answer
I'm not sure why I'm doing anything in this regards. Searching a bit, reading a bit and trying to learn a bit... But, don|t really know where I could find httpd.conf on my server or how to use it... Do you have some links to some good informative information I could read? – ThomasK Jul 5 '12 at 11:05
httpd.conf has lots of practical info inside. It should be located in Linux in /etc/apache2/ or in Windows in installation_directory/etc or installation_directory/conf, where installation_directory is probably c:\Program files\Apache2 – DSkowronski Jul 5 '12 at 14:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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