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
11 weeks 9 hours ago
14 weeks 1 day ago
16 weeks 5 days ago
25 weeks 2 days ago
26 weeks 2 days ago
29 weeks 5 days ago
29 weeks 6 days ago
30 weeks 1 day ago
30 weeks 2 days ago
30 weeks 2 days ago