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 Answer
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]
-
2Should be noted that Drush will nuke any .htaccess files when updating Drupal core.– aendraCommented Apr 8, 2013 at 18:05