- Issue created by @andrea.cavattoni
- 🇮🇹Italy andrea.cavattoni
I was planning to make a script and create redirects with https://www.drupal.org/project/redirect → to all files in the db in the public folder as I was lookin in the module code and I dont see any redirect functionality.
Please let me know - 🇮🇹Italy andrea.cavattoni
Just made the script, sounds good or should we take a different approach:
//LOAD S3 FILES AND NOT FOLDERS $query = db_select('s3fs_file','sf'); $query->fields('sf'); $query->condition('sf.dir',0); $files = $query->execute()->fetchAll(); foreach($files as $f){ //LOAD LANGUAGE //TODO CHECK DIFFERENT FILE LANGUAGES global $language; //BUILD THE PATH FOR REDIRECT $path = array( 'source' => str_replace('public:/', 'sites/default/files', $f->uri), 'destination' => file_create_url($f->uri), 'language' => $language->language ); //CREATE THE REDIRECT $redirect = new stdClass(); redirect_object_prepare($redirect); $redirect->source = $path['source']; $redirect->redirect = $path['destination']; $redirect->language = $path['language']; //CHECK IF REDIRECT EXISTS $hash = redirect_hash($redirect); $existing = redirect_load_by_hash($hash); if (!$existing) { redirect_save($redirect); } }
- Status changed to Closed: outdated
3 months ago 10:19pm 14 January 2025 - 🇺🇸United States cmlara
Drupal 7 end-of-life triage:
Drupal 7 reached end of life on January 5th.The 7.x branches of S3FS do not have any additional planned releases.
This issue is not specifically S3FS related and no such feature is planned in newer version of the module.
The methods for this would be applicable to any sort of deployment of Drupal where files have moved. I would encourage site owners to consider the possibility of redirecting at the server config level to avoid a Drupal bootstrap.