I have the Redirect module installed, but when I add a redirect from an existing file to a new file, the redirect doesn't activate.

I did some digging and found a post suggesting that Drupal can't redirect a file if it already exists, it can only redirect from 404 or pages. Is this true? Is there really no way to redirect from an existing file?

And if it is true, how do I delete the file? There doesn't seem to be a way to delete a file once it is uploaded. The file was originally attached to a content item but that content has since been deleted.

  • Check "Delete orphaned files after ..." in /admin/config/media/file-system
    – 4uk4
    Jan 6, 2017 at 7:22
  • Yes, that is checked and has been.
    – RayB
    Jan 7, 2017 at 1:28

1 Answer 1


The redirect rules in .htaccess that cause Drupal to be fired up only happen if/when an actual file doesn't exist. For example, if I have a file in my webroot named file.txt, and I go to example.com/file.txt, Drupal will not start, as the file exists. If that file does not exist, Drupal will be fired up, and show a 404 page (unless you have an alias in Drupal for the path /file.txt). You have said the file exists on your system, which means Drupal is not being started up when someone accesses that file, and therefore the redirect module will not work.

As for how to delete the file, you say the content item has been deleted. This should also result in the file being deleted, though it does not appear that it was. I'd do a search through the {file_managed} table in the database to make sure it's not still in there for some reason - maybe the file is still attached to a different piece of content or something. If you're absolutely sure the file does not exist in Drupal anymore, then you can log into your server (ftp, ssh etc) and manually delete the file.

  • The file was originally attached to a content item but that content has since been deleted. Added this to my post.
    – RayB
    Jan 6, 2017 at 3:19
  • Updated accordingly.
    – Jaypan
    Jan 6, 2017 at 4:48
  • The file is still there. I also tried uploading a PDF to a new page, and then deleting that PDF. The PDF is still accessible despite me deleting it with the Drupal interface. I have Workbench Moderation installed, do you think this is interfering with the deletion?
    – RayB
    Jan 7, 2017 at 1:27
  • By 'still there' you mean still in the database?
    – Jaypan
    Jan 7, 2017 at 1:31
  • Sorry, still accessible / on the server. I don't have access to view the database until Monday.
    – RayB
    Jan 7, 2017 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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