“Tinyurl”-ify DropBox Public Links With .htaccess

By | 2008/11/08

I just recently started using DropBox on Ubuntu 8.10 “Intrepid Ibex” and leftyfb in IRC pointed out to me a nifty little trick with .htaccess files.  If you’ve been using DropBox I’m sure you’ve seen or made use of the Public folder and sharing files.  You may have also noticed that the DropBox Public links are long and likely hard to remember when needed.

One thing that you can do, if you have your own web server, is dynamically generate these public links.  For example:

Original DropBox Public URL:

http://dl.getdropbox.com/u/312414/Christer_Edwards.asc

DropBox Public URL with .htaccess trick:

http://zelut.org/dropbox/Christer_Edwards.asc

In order to accomplish this you’ll need access to a webserver and the ability to create and use a .htaccess file.  On my webserver I created a folder called “dropbox” and then pasted the following into a new file, .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://dl.getdropbox.com/u/012345/$1 [L,QSA]

You will need to replace the “012345” with your unique ID.  As you notice from the original link above, my unique ID is “312414”.  You can find yours by copying the public link within Nautilus.

Once this is done you can share files by placing them into your DropBox Public folder and then appending the filename to your webserver URL + created folder.  Again, since I created the folder “dropbox” on http://zelut.org/, my url is http://zelut.org/dropbox/.  I simply append the filename I want to share and its done!

If anyone can suggest a way to present this URL with an index.html that may be a cool trick.

6 thoughts on ““Tinyurl”-ify DropBox Public Links With .htaccess

  1. Christer Edwards Post author

    @Vinicius – if you right-click a file within Dropbox/Public and select Dropbox > Copy Public Link, you can then paste that link anywhere. The userID you’re looking for is the 6 digits just after /u/.

  2. Pet

    Great Tip.

    I have a question if I follow your .htaccess trick will my server download the file first from dropbox and then stream it to the user?

    The reason I’m asking is because I have pretty heavy files on my public folder and I do not want to have to pay for additional bandwidth.

    Chers,

    Pet

    1. Christer Edwards Post author

      Pet – your server won’t download anything from Dropbox. All it is doing is abstracting the URL to something more manageable and forwarding the user directly to the Dropbox share.

Comments are closed.