0

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?

2 Answers 2

-1

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

2
  • 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, 2012 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, 2012 at 8:34
0

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.

2
  • 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, 2012 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 Jul 5, 2012 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .