Online files stored on a web server have, most of the time, many references pointing to these files.

In my case, my web hoster decided that I had to take away files stored in a folder called downloads. However many links from my phpbb3 forum pointed to that directory. Needless to say, that this would require a lot of manual work adjust all these links.

An automatic solution would have been: Change URLs. However this would only have covered the phpbb3 forum referenced URLs, not some links I send friends in order to download stuff.

A much more elegant server based solution is to work with .htaccess redirection/rewrite mechanisms.

URL pointing to this directory:
URL should be redirected to this directory:

The following .htaccess file, located in the downloads directory, rewrites URLs:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,L]

The user doesn’t even notice that the files are downloaded from a different location than the announced URL.