apache LocationMatch and Basic Auth

2.2k Views Asked by At

Is there any way to get matched substring from LocationMatch and use it as part of configuration? I have several similar sites that uses apache Basic auth and want to check against "sitename".passwd files..

in code I mean this but working:

<LocationMatch /([^/]+)/login>
  AuthType Basic
  ...
  AuthUserFile /var/sitepwds/$1.passwd
</LocationMatch>
1

There are 1 best solutions below

0
On BEST ANSWER

Use mod_macro for that.

Write:

<Macro MyMacro $name>
<LocationMatch /$name/login>
  AuthType Basic
  ...
  AuthUserFile /var/sitepwds/$name.passwd
</LocationMatch>
</Macro>

and use it like:

Use MyMacro site1
Use MyMacro site2
Use MyMacro site3
...