download_url; header("Location: $random_image_path"); } // if the current URL is in the form "/images/...", show the image if (preg_match("/\/images\/(.*)$/", $_SERVER['REQUEST_URI'], $matches)) { $image_path = $BASE_URL . $matches[1]; header("Location: $image_path"); } ?>