0

Here's a picture of a folder inside the root directory my website:
Directory
I want to have htaccess require an authentication to access any of these folders. So no one can type in www.domain.com/Folder/CSS and access it without the correct username and password. So far I've tried:

<DirectoryMatch "^*">
    AuthType Basic
    AuthName "Login"
    AuthUserFile /disks/*/*/Folder/.htpasswd
    Require valid-user
</DirectoryMatch>

This is to make it secure all the subdirectories (classes, cs, images, js) but instead when I type in www.domain.com/Folder/Front.php it comes up with:

Internal Server Error

With no console error. How do I make htaccess authenticate all the subdirectories (BUT NOT FRONT.PHP!)?

Jake McGraw
  • 55,558
  • 10
  • 50
  • 63
Charlie Yabben
  • 307
  • 2
  • 7
  • 13

1 Answers1

0

Try change the DirectoryMatch regex to /(.+)

There is a tester for regex here...

Hope that helps

Cheers Robin

Ps: what do the apache logs say? Have you turned on logging.

Robin Rieger
  • 1,204
  • 1
  • 16
  • 37
  • This didn't work and I don't have access to the logs. I've tried `"/(.+)"`, `/(.+)`, `"^/(.+)"`, `^/(.+)`. None of them worked. Any ideas? – Charlie Yabben Oct 16 '12 at 18:41
  • and if you put the following inside the directorymatch Satisfy any That won't catch just / but if you type the page name then it will not ask for password... – Robin Rieger Oct 16 '12 at 22:18
  • so do you have any other solution? – Charlie Yabben Oct 17 '12 at 19:30
  • Nope sorry mate. Can't get it working. Tried different things like: `([^/].*[/])` and `(^[/])` and `(/.*/).*` and `(^/[^/]*$)` and `^[/.*/]` etc, but none of them seem to 'get' the root without anything in the url. Can I recommend if it is the main page to do a R=301 on / to /Frontpage.php. Your problem goes away then because you can simple match all real files with a FilesMatch directive and then `Satisfy any` them... Hope that works for you... – Robin Rieger Oct 17 '12 at 21:49