locally host a working website
You have an .htaccess rewrite rule / PHP redirect moving all traffic to https://www.example.com when the domain/protocol doesn't match.

If it's in .htaccess look for these lines and comment them out:

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


If there's an http -> https redirect that will have been set up manually (the above is included in the core .htaccess), so you'll need to locate and remove that separately.

If it's in PHP, it typically happens in settings.php. You should be able to see what's doing it fairly easily and comment out/remove for your local environment.

Failing that, you'll probably need to trawl the code to find out what's responsible for the redirect.