locally host a working website I'm trying to locally host an already working/hosted website using wampp to try and edit it without messing up the site. But every time I try to open the site using localhost/example, it automatically redirects to the hosted domain(https://www.example.com). Can someone help me solve this issue?
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.