How can the code snippet provided be improved to ensure proper redirection to the subdirectory?

The issue with the current code snippet is that the redirection to the subdirectory is not done correctly. To ensure proper redirection, we need to include the subdirectory in the URL when performing the redirection. This can be achieved by appending the subdirectory name to the base URL before redirecting.

<?php
// Get the base URL of the website
$base_url = "http://$_SERVER[HTTP_HOST]";

// Specify the subdirectory to redirect to
$subdirectory = "/subdirectory";

// Perform the redirection to the subdirectory
header("Location: $base_url$subdirectory");
exit;
?>