Enabling WebDAV on Apache

These instructions will set up WebDav in a website's /share URL + folder with correct user/realm/password authentication (AuthType: Digest, not Basic). This will enable you to map a network drive with the native Windows XP/Vista/7 WebDav client (Microsoft-WebDAV-MiniRedir).

The setup:

Apache's httpd-dav.conf

Edit file C:\WampDeveloper\Config\Apache\extra\httpd-dav.conf and replace all contents with this code.

Note: only do this if you are using WampDeveloper Pro Pro v4.0.3.3 and below. Newer versions already have the proper httpd-dav.conf file.

# Distributed authoring and versioning (WebDAV)
# The User/Group specified in httpd.conf needs to have write permissions
# on the directory where the DavLockDB is placed and on any directory where
# "Dav On" is specified.

<IfModule !dav_module>
	LoadModule dav_module modules/mod_dav.so
<IfModule !dav_fs_module>
	LoadModule dav_fs_module modules/mod_dav_fs.so

<IfModule !auth_basic_module>
	LoadModule auth_basic_module modules/mod_auth_basic.so
<IfModule !authn_file_module>
	LoadModule authn_file_module modules/mod_authn_file.so
<IfModule !authz_user_module>
	LoadModule authz_user_module modules/mod_authz_user.so
<IfModule !authz_groupfile_module>
	LoadModule authz_groupfile_module modules/mod_authz_groupfile.so

<IfModule !auth_digest_module>
	LoadModule auth_digest_module modules/mod_auth_digest.so

<IfModule !setenvif_module>
	LoadModule setenvif_module modules/mod_setenvif.so
<IfModule !alias_module>
	LoadModule alias_module modules/mod_alias.so

DavLockDB "C:/WampDeveloper/Temp"
DAVMinTimeout 600

# The following directives disable redirects on non-GET requests for
# a directory that does not include the trailing slash.  This fixes a 
# problem with several clients that do not appropriately handle 
# redirects for folders with DAV methods.

BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully

If your WampDeveloper Pro installation is not in C:\WampDeveloper\, edit this file to update the DavLockDB path.

Save file.

Apache's httpd.conf

Edit file C:\WampDeveloper\Config\Apache\httpd.conf and uncomment line 167 (remove #)...

Include C:/WampDeveloper/Config/Apache/extra/httpd-dav.conf

Save file.

Website's VirtualHosts

Edit your website's VirtualHost files... In WampDeveloper Pro's Websites Tab, select website, click both the HTTP and SSL VirtualHosts buttons.

Within the VirtualHost block add in:

# Uncomment if /share is to be the WebDav root
# of the entire website structure (and is not just a specific subfolder)

# Alias /share "C:/WampDeveloper/Websites/www.example.com/webroot"

<Location /share>
  # turn off PHP as otherwise WebDav GET requests will execute PHP scripts
  php_flag engine off
  # turn off SSI and CGI
  Options -Includes -ExecCGI
  # Uncomment to prevent .htaccess files from overriding above settings
  # AllowOverride None
  # Uncomment to turn off any existing rewrite rules
  # Rewrite engine off
  Dav On
  AuthType Digest
  AuthName "dav"
  AuthDigestProvider file
  AuthUserFile "C:/WampDeveloper/Websites/www.example.com/htpasswd/share/.htpasswd"
  <LimitExcept GET OPTIONS>
    Require valid-user

Save files.

User/password File

Create the above "AuthUserFile" path and .htpasswd file with the proper username, realm, and password...

Note: the realm has to match the above "AuthName" exactly.

In WampDeveloper Pro's System tab click the Command Line button. This will open the command line/prompt in the C:\WampDeveloper directory.

  1. cd Websites/www.example.com/
  2. mkdir htpasswd
  3. cd htpasswd
  4. mkdir share
  5. cd share
  6. htdigest -c .htpasswd dav admin
  7. Enter password: passadmin

Restart Apache.

Map Network Drive

When you are ready to connect to the WebDav share, you can use the native Windows WebDav client to do so...

  1. Start > Computer > Map Network Drive
  2. Drive: Z
  3. Folder: http://www.example.com/share
  4. De-select: Reconnect at logon
  5. Click: Connect using a different user name: admin, passadmin
  6. Click: Finish


"WebDAV may be unable to properly check out any files with dynamic content like PHP tags or SSIs because the HTTP GET renders these as they are checked out."
Using DreamWeaver and WebDAV to check in and check out files.

"AuthType Basic" is not supported by the native Windows WebDav client.

By using "<LimitExcept GET OPTIONS>" we are allowing browser pageviews without having to log in (read access allowed, write access is restricted).

When adding more users via htdigest.exe, do not use the "-c" switch. This switch simply creates an empty file.