WebDAV

From DreamHost

Jump to: navigation, search

WebDAV, or Web-based Distributed Authoring and Versioning, is an extension to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers. The World Wide Web, as conceived by Tim Berners-Lee, was always intended to be a readable and writable medium; however, as the web grew it became a largely read-only medium. WebDAV has emerged as a way to restore that functionality, although it is no longer concerned with the versioning aspect - just the distributed authoring part.

To avoid problems with WebDAV on the server keep reading. However, if you just need to know how to access a WebDav directory from your local machine, read WebDAV_How-To_Access.

One problem with WebDAV is that it does not allow you to edit the source of server processed files, including PHP, shtml, Perl, etc. This is because it uses the same command to "GET" the file as your web browser. The webserver has no way of knowing to not process the php file and give you the output instead of the source code. Adding this line to your .htaccess file will disable all processing:

SetHandler default-handler

Meaning .php files will show their source, including any passwords you have coded in. You will need to get support to add this line, as well as change the permissions to allow you to edit the file. Any changes made to this file will be overwritten if you make any changes in the panel to your htaccess/webdav options.

Contents

Using WebDAV for an entire domain

You can't currently use WebDAV for an entire domain hosted by Dreamhost but, using the magic of Apache's rewrite module, you can make it seem like you are.

A note of caution

WebDAV uses it's own .htaccess and .htpassword file which are controlled by the WebDAV interface and may not always be visible. This may cause "abnormal" behavior in certain instances, such as creating a WebDAV directory off of your domain's root directory (e.g. http://example.com/webdav/). There is at least one incident where doing this caused processing of the pre-existing .htaccess file to silently fail resulting in no page display. It is suggested that if you're creating a WebDAV directory, you ensure that the target WebDAV (as well as it's parent) are reasonably isolated from your main site.

Step 1

Use the WebDAV goodies panel to setup a directory with WebDAV enabled. For the rest of this guide it will be assumed that the directory is called "site".

Step 2

If you already have any data or directories you want to be part of the new WebDAV site then connect to your new WebDAV share and upload them there. The URL of your WebDAV share should be something like http://yourURL/site/. Don't worry about modifying the links within your pages. The magic we will do in the next step means they will still work exactly the same way they currently do.

Step 3

Now we have to use a .htaccess file to rewrite requests to http://yourURL to use the data stored in http://yourURL/site/ (afterwards visitors wont even know it's happening). In the main folder for your domain you should put a file called ".htaccess". Make sure you include the period at the start. Put the following text into the file:

RewriteEngine on
RewriteCond %{REQUEST_URI} !site/
RewriteRule ^(.*)$ /site/$1

The first line turns on rewriting. The second line tells the webserver not to rewrite http://yourURL/site/ and the third line line tell the webserver to rewrite all requests to http://yourURL/ to use the data from http://yourURL/site/. If you have directories that you don't want to be under WebDAV control then you should add additions RewriteCond lines like the one for "sites". For example if you don't want the directory "scripts" to be rewritten you would add the line:

RewriteCond %{REQUEST_URI} !scripts/

Conclusion

That's it! When you surf to http://yourURL/ you should actually be sent the data from http://yourURL/site/ but your URLs will look exactly the same as they did before.

https WebDAV

If you want to use WebDAV over https - it is possible but you will need to have a unique IP address. You need to enable the SSL service on your actual domain name. You will then be able to access WebDAV via SSL. You can set up this secure service for your domain by clicking the 'edit' button located under the 'Secure Hosting' column next to your domain here:

https://panel.dreamhost.com/index.cgi?tree=domain.manage

External links

Personal tools