1 file.inc file_ensure_htaccess()

Creates a .htaccess file in each files directory if it is missing.

Related topics

File

core/includes/file.inc, line 476
API for handling file uploads and server file management.

Code

function file_ensure_htaccess() {
  // No need to create htaccess files if not running Apache.
  if (!backdrop_is_apache()) {
    return;
  }

  file_save_htaccess('public://', FALSE);
  if (config_get('system.core', 'file_private_path')) {
    file_save_htaccess('private://', TRUE);
  }
  file_save_htaccess('temporary://', TRUE);
}