Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
</FilesMatch>

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

2 Answers 2

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 http://httpd.apache.org/docs/2.0

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

 
discard

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.