What are the best practices for sending HTTP requests in PHP to avoid page redirection?

When sending HTTP requests in PHP, it's important to set the 'allow_redirects' option to false in order to avoid automatic redirection. This can be achieved by using the Guzzle HTTP client library and setting the 'allow_redirects' option to false in the request configuration.

<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();

$response = $client->request('GET', 'http://example.com', [
    'allow_redirects' => false
]);

echo $response->getBody();