Monday, April 19, 2010

Drupal 6 Shortened URL to Files Directory

We recently had a situation where a client wanted shorter URLs since they were sending out emails and e-newsletters to clients and wanted things shortened up. Since Drupal 6 requires that uploaded files have the entire path it is obvious how that can be an eyesore for some people.

Current URL:
http://{domain}/sites/{domain or alias}/files/{file}.{extension}

A workaround is to go to the file system on the Drupal directory (/usr/share/drupal6) and create a symbolic link to the directory.

user@machine /usr/share/drupal6> ln -s /sites/{domain or alias}/files/{file}.{extension} {short-alias}

Example:
user@machine /usr/share/drupal6> ln -s /sites/blogger.com/files/ mbf

So the new URL becomes:
http://{domain}/mbf/{file}.{extension}

No comments: