In a site I was recently working on, I found myself hard-coding links to files stored within my Drupal site's "files" directory. If you've ever coded these links before, you know that they normally look something like:
/sites/[sitename]/files/[someotherdirectory]/image.jpg
This can be somewhat painful to add to the site, especially if you have any plans to ever change the domain name of your site. It would really be ideal if you could leave the domain name out of the equation and just write the link in the format:
/files/[someotherdirectory]/image.jpg
This is actually possible to do using the .htaccess file that appears in the root of your Drupal installation. Basically you just need to add a single line:
RewriteRule ^files/(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]
After you implement this rule, you should be able to start writing simpler links to your "files" directory.
Happy coding!

Recent comments
5 weeks 3 days ago
6 weeks 3 days ago
9 weeks 6 days ago
10 weeks 1 hour ago
10 weeks 2 days ago
10 weeks 3 days ago
10 weeks 3 days ago
20 weeks 5 days ago
23 weeks 1 day ago
31 weeks 5 hours ago