When I query from the WordPress site, it automatically redirects to the spam site
My WordPress site automatically redirects to spam sites when I query it from a search engine.
I'm having problems with a WordPress site installed on my VPS. When I query it directly using the URL, it works fine without any problems. But when I or a client query the same site from a search engine, it redirects to spammy sites, which has led to some people getting scammed.
I have checked the site code changes several times to see if it was hacked, but this way is not useful. I can easily check because I use git to control the version of the project.
I updated all the plugins in case the problem was with them, but nothing happened.