2

I am using Drupal 7. Is it possible to to redirect the "/sites/all/files" directory to just "/files". Also, would it be better to just create a new directory /files and copy the files over. But, I would have to change a lot of links in my content that access those files.

  • 1
    If your links are embedded in content I think you might need to update them manually (or at least build a script to do it). To actually move the files folder there's a guide available – Clive Jan 21 '13 at 18:53
5

With Drupal 7, you do not need to do so! Drupal file paths are stored using stream wrappers so you can simply change the folder path in Admin > Configuration > Media File System and move the existing files to new folder and you are ready to go!

You will see public://images/my.png like paths in files table and many other locations. These are the stream wrappers used in Drupal 7.

However if your content has links hardcoded, they will not change. Try adding the following line right below the

RewriteEngine on
RewriteBase /

lines.

RewriteRule ^sites/default/files/(.*)$ http://www.example.com/files/$1 [R=301,L]
  • 2
    Should be noted that Drush will nuke any .htaccess files when updating Drupal core. – aendrew Apr 8 '13 at 18:05

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.