Making directories browsable, solving 403 errors


  • Applies to: Grid
    • Difficulty: Medium
    • Time: 10
    • Tools needed: FTP, plain text editor or SSH, vi knowledge
  • Applies to: All DV
    • Difficulty: Medium
    • Time: 10
    • Tools needed: FTP, plain text editor or SSH, vi knowledge

Overview

Make a directory web-browsable. For example, if you have several files uploaded to http://example.com/files/, you may want to make them available over the web for browsing and downloading. This is a convenient way to share files over the web without FTP (at least on the downloading side - they still have to be uploaded with FTP).

By default, a 403 Forbidden error will display if you visit the URL for a folder on your server that does not contain an "index.html" or "index.php" page. The other contents of the directory will not be displayed. Following the steps in this article will instead cause a list of files to be displayed.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Requirements

  • You CANNOT have a file called "index" of any type in the directory you are trying to make web-browsable. That will override the file list.
  • The .htaccess file will apply to subdirectories as well. They will also become browsable.

Instructions

  1. Add the following line to your .htaccess file:

    Filename: .htaccess

    
    Options +Indexes
    

    Please see our article on the .htaccess file for instructions on the best way to create and upload this type of file.

  2. Upload this file to the directory you want to make web-browsable on your Grid. This should be domains/example.com/html/ or a subdirectory. You will need to upload the file through FTP. Keep in mind that all subdirectories will also be made browsable.
  3. Upload this file to the directory you want to make web-browsable on your DV server. This will need to be in /var/www/vhosts/example.com/httpdocs/ or a subdirectory. You can upload the file via FTP. Remember that all directories below this level will also become browsable.

That's it! You should now be able to visit the URL that points to that directory and view a list of that directory's contents over the web.

Quick guide to making a password-protected download directory

This is a quick guide to making a protected download area on your site.

  1. Connect to your server via FTP.
  2. Navigate to domains/example.com/html/. Replace example.com with your own domain name.
  3. Create a new folder. In this example, we will use the folder downloads. See your FTP program documentation for specific instructions on how to create a new folder.

    TIP:

    Right-click to see if creating a new folder is an option.

  4. Follow the Instructions section above to create and upload the appropriate .htaccess file. It needs to be uploaded to your downloads directory, or whichever directory you want to use for your downloads.
  5. Verify that you can now view the contents of the downloads directory by visiting http://example.com/downloads/ in your browser. Replace the example URL with your own domain and new folder.
  6. Password protect this directory through the AccountCenter, by following the instructions here: Password protecting directories.
  7. Password protect this directory. You can do this within Plesk by following the instructions here:
  8. Now, double-check your URL in your browser again. You should be prompted for a username and password. Once you log in, you will see your files displayed. Click on a file to view or download. If the file opens in the browser, you can right-click to download it instead.

TIP:

This is a very utilitarian solution for browser file downloads. If you're looking for something a bit prettier, check out the following free software:

All third-party applications are not supported by (mt) Media Temple.