Forum

Password protected directory/file inside VirtualHost section

Bier
29 October 2015, 11:03
Hi,

at the moment I'm using a Directory section to password protect a directory of my VirtualHost:
VirtualHost {
Hostname = example.com
WebsiteRoot = /srv/www/example.com
StartFile = index.php
UseFastCGI = PHP5
UseToolkit = wordpress
LoginMessage = wp-admin
}

# DIRECTORY SETTINGS
# You can specify some settings per directory.
#
Directory {
Path = /srv/www/example.com/wp-admin/
PasswordFile = digest:/etc/hiawatha/htpasswd.wp-admin
}


What I don't like with this approach is that I have to specify the directory twice: the webserver root and the password protected dir. Is it possible to specify the protected directory as relative path to the web server root?
Hugo Leisink
30 October 2015, 08:02
That would be a significant change in how Hiawatha works. I will think about it. If I ever accept this change, it won't be soon.
Bier
30 October 2015, 08:32
Hi Hugo,

thanks for your response. OK, so that is not possible right now. I've thought I've missed something Another approach could be a rule in the toolkit. Something like this:
UrlToolkit {
ToolkitID = wordpress
Match ^/wp-admin/ PasswordFile = digest:/etc/hiawatha/htpasswd.wp-admin
RequestURI exists Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}

What do you think about it?
Bier
30 October 2015, 10:59
Using the toolkit would also make possible to protect a file rather than a directory.
Hugo Leisink
2 November 2015, 21:24
I don't want to put more options in the UrlToolkit, but I'll think about the concept in a more general form.
This topic has been closed.