diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
index 4535684..62c8448 100644
--- a/src/wp-admin/includes/file.php
+++ b/src/wp-admin/includes/file.php
@@ -2030,14 +2030,19 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
 		wp_send_json_error( __( 'Unable to create export folder.' ) );
 	}
 
-	// Protect export folder from browsing.
-	$index_pathname = $exports_dir . 'index.html';
+	// Protect export folder from browsing and delete legacy index.html file.
+	$legacy_index_pathname = $exports_dir . 'index.html';
+	$index_pathname = $exports_dir . 'index.php';
+	if ( file_exists( $legacy_index_pathname ) ) {
+		unlink( $legacy_index_pathname );
+	}
 	if ( ! file_exists( $index_pathname ) ) {
 		$file = fopen( $index_pathname, 'w' );
 		if ( false === $file ) {
 			wp_send_json_error( __( 'Unable to protect export folder from browsing.' ) );
 		}
-		fwrite( $file, 'Silence is golden.' );
+		fwrite( $file, "<?php \n");
+		fwrite( $file, "// Silence is golden." );
 		fclose( $file );
 	}
 
