I want to move the CSS and JS cache folders (sites/default/files/css and sites/default/files/js to another place. Is this possible?

I want to do this because I'm planning to have the files folder on a remote file system and I think that accessing the CSS and JS from remote would slow down the site.

Edit: I'm using Drupal 6.


I'm not saying this is the best or correct way to do it, but I think you could use hook_file_url_alter to change the url for your script and stylesheets:

 function hook_file_url_alter(&$original_uri) {
      // rewrite url for your javascript files
      if(strstr($original_url, 'sites/default/files/your-script.js')) {
          $original_url = 'http://example.com/js/your-script.js';

Try using File Aliases

The File Aliases module allows you to use token customizable aliases for your uploaded files, giving you the ability to keep your file system organized as per usual while providing clean looking paths (i.e., no more '/sites/default/files/').


  • Customizable File Alias field using Node tokens.
  • Support for:
    • Drupal core Upload module.
    • FileField module.
    • ImageField module.
    • Image module.
    • Comment Upload module.
  • Support for Private and Public file systems.
  • Support for Views output (Fields and Nodes).
  • Support for FileField Paths Retroactive and Active Updating.

Required Modules:

  • FileField Paths (6.14 or greater)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.