I recently upgraded Apache from 2.2 to 2.4 and among all the expected changes that had to be made to the existing sites-available config files, I encountered an unexpected issue with the WebDAV sites.
I could connect to the sites via DAV but weirdly enough I could not open some directories with them. I would get a “405 Method Not Allowed error”.
It turns out that if a collection in a WebDAV-enabled area contains an index.html (or whatever filename is specified in DirectoryIndex – index.php, default.html, etc.) then it becomes impossible to use WebDAV methods on that collection. See bug report.
In order to fix this, you need to disable directory indexing for the WebDAV site(s).
If you still want to have directory indexing when serving regular http requests, I recommend having WebDAV configured on a different port.
I normally have development sites, server reqular requests on port 80 and have the WebDAV configured on port 443.
So, in your sites-available/site.conf file, in the corresponding VirtualHost declaration add DirectoryIndex disabled to the Directory declaration, like so:
<Directory /path/to/my/webdav/dir> Options Indexes FollowSymLinks MultiViews AllowOverride all Require all granted DirectoryIndex disabled </Directory>
Here is an example config file:
DavLockDB /webdav/DavLock/DavLock <VirtualHost 188.8.131.52:80> ServerAdmin webmaster@localhost ServerName my.domain.com DocumentRoot /var/www/my.domian.com/ Alias /web /path/to/my/webdav/dir <Directory /path/to/my/webdav/dir> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all granted </Directory> </VirtualHost> <VirtualHost 184.108.40.206:443> DocumentRoot /var/www/my.domian.com/ ServerName my.domian.com ServerAlias my.domian.com 220.127.116.11.my.domian.com Alias /web /path/to/my/webdav/dir <Directory /path/to/my/webdav/dir> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all granted DirectoryIndex disabled </Directory> <Location /web> DAV On AuthType Digest AuthName "the_auth_name" AuthUserFile /the/digest.dav Require valid-user php_value engine off RewriteEngine off </Location> SSLEngine on SSLOptions +StrictRequire SSLCertificateFile /etc/ssl/certs/mydomain.com.crt SSLCertificateKeyFile /etc/ssl/private/mydomain.com.key SSLCACertificateFile /etc/ssl/certs/mydomain.com.cabundle.crt </VirtualHost>
Then just reload Apache and you will no longer have that issue:
sudo service apache2 reload