Overview
This article explains how to enable WebDAV in your DreamHost panel.
No access to your .htaccess and .htpasswd files
The instructions in this article create an .htaccess and .htpasswd files which will be owned by the server. This means you will not be able to manually edit either of these files if you need to. Additionally, these instructions will overwrite any existing .htaccess file. Make sure to backup your existing .htaccess file before beginning these steps.
If you only need to password protect your site and will need access to your .htaccess and .htpasswd file at any time in the future, you should follow the directions in the following article instead.
These instructions walk you through how to manually create your .htaccess and .htpasswd file.
HTTPS
If you'd like to access your WebDAV directory over a secure connection, you must purchase an SSL certificate. Visit the following article for further details:
Enabling
- Navigate to the Htaccess/WebDAV page.
- In the list of domains, click the site on which you wish to enable WebDAV.
- Click the Set up a New Directory button to continue.
- Enter the following:
- Directory name: The subdirectory you want to use for WebDAV. If this directory doesn't exist, then it's created automatically.
- Password-protect this dir?: You should check this box for security purposes.
- Enable WebDAV on this dir?: Check this box.
- Directory "name": When you navigate to the WebDAV directory, a pop-up box opens, allowing you to log in. This text is what appears in that box.
- User accounts for this area: Add a user followed by its password. View the Passwords article for instructions on how to create a safe password.
- Forbid linking to files in this dir?: Check this box if you'd like certain file types to be forbidden.
- Forbidden file extensions: Add the forbidden extensions here.
- Domains that may still link: Add domains that will not be forbidden from accessing this content.
- Click the Configure This Directory button to save.
If you have a lot of directories you wish to enable WebDAV on, you must add users for each directory separately via the panel. Also, users have access to the entire directory once created.
Enabling WebDAV on an entire domain, not just a sub-folder
Creating the WebDAV directory in your DreamHost panel does not allow you to apply WebDAV to an entire domain – it only works on the specific subdirectory. However, using an .htaccess file, you can make it so WebDAV works when visiting the site's URL without the subdirectory.
WebDAV uses it's own .htaccess and .htpasswd 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., https://example.com/webdav/). It is suggested that if you're creating a WebDAV directory, you ensure that the target WebDAV (as well as its parent) are reasonably isolated from your main site.
- Visit the Htaccess/WebDAV page to set up a directory with WebDAV enabled.
- For the rest of these steps, it's assumed that the directory is called "site".
- If you already have any data or directories you want to include in the new WebDAV site, connect to your new WebDAV share and upload them. The URL of your WebDAV share should be something like https://example.com/site/.
- Don't worry about modifying the links within your pages – they will still work exactly the same way they currently do.
- In the main folder for your domain, create 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 https://example.com/site/.
- The third line tells the webserver to rewrite all requests to https://example.com/ to use the data from https://example.com/site/.
- If you have directories that you don't want to be under WebDAV control, add additional RewriteCond lines like the one for "site". For example, if you don't want the directory "scripts" to be rewritten, then add the following:
RewriteCond %{REQUEST_URI} !scripts/
When you now visit https://example.com/ you should actually be sent the data from https://example.com/site/, but your URLs will look exactly the same as they did before.
Disabling
- Navigate to the Htaccess/WebDAV page.
- In the list of domains that appear, click the site on which you wish to disable WebDAV.
- Click the Delete button to continue.
- When the confirmation box prompts you, click OK to complete the process.