Back to Articles

Website Hacked or Defaced? What to Do First, and How to Stop It Happening Again

Last updated:

Close-up of a leaded glass window with one cracked pane beside a new green pane fitted into place, illustrating recovering a hacked website

Sometimes it is obvious: the homepage has been replaced by a message from whoever broke in. More often it is quieter. A customer says your site sent them to a betting page, Google shows "This site may be hacked" under your name, or your host emails to say the account is suspended for sending spam. However you found out, the next few hours decide how much it costs you.

This guide is written for the site owner. It covers what to do immediately, how to choose between restoring, cleaning and rebuilding, how to find the way in, and how to get Google to stop warning visitors away. The order matters more than any single step.

How can you tell if your website has been hacked?

A hacked website usually shows itself through symptoms you can check in minutes: pages you did not create appearing in Google, visitors being redirected elsewhere, a browser or Google warning, unknown administrator accounts, or a message from your host. A defaced site, where the visible content is replaced, is the loud version of the same problem.

Many hacks are built to stay hidden from the owner. A common pattern serves normal pages to you and spam or redirects only to search engines or to visitors arriving from Google, so the site looks fine when you type the address yourself. That is why checking from the outside matters.

The quickest checks:

  • Search Google for site:yourdomain.com. Pages in other languages, pharmacy or casino keywords, or thousands of URLs you never made are a classic sign. Google calls one common form the "Japanese keyword hack".
  • Open the site from a phone on mobile data, arriving through a Google result, not by typing the address. Some redirects only fire for that kind of visit.
  • Look at Google Search Console's Security Issues report. If Google has detected hacked content or malware, it is listed there with sample URLs.
  • Check Google's Safe Browsing site status at transparencyreport.google.com for your domain.
  • List the administrator accounts in your CMS. An admin you do not recognise means someone has had full control.
  • Read any email from your host about suspension, high resource use or outgoing spam. Hosts often notice before owners do.

What should you do in the first hour after a hack?

Contain the damage and save the evidence before you change anything. Put the site into maintenance mode or ask your host to take it offline, copy the files, database and logs before changing anything, then change every password from a device you trust. Do not delete or restore anything yet.

The urge is to fix the visible damage at once, especially on a defaced homepage. Wait. If you restore a clean copy over a site whose way in is still open, the attacker is usually back within days, and you will have overwritten the evidence that showed how they got in.

A first-hour checklist:

  • Take the site offline or into maintenance mode, so visitors and Google stop seeing the hacked version and nobody is sent to a malicious page.
  • Tell your hosting provider. They can see server logs, block abusive traffic and tell you whether other sites on the account are affected.
  • Copy everything as it is now: files, database and access logs. Logs rotate and get deleted, and they are the best record of how the attacker came in.
  • Change passwords from a clean device, not the one you suspect: hosting, CMS administrators, FTP or SFTP, database, domain registrar and the email accounts linked to them. Turn on two-factor authentication wherever it is offered.
  • Write down the timeline: when you noticed, what you saw, who you have told. You may need it for customers, your host or a lawyer.

Should you restore a backup, clean the site, or rebuild it?

Restore from a backup when you have a copy you are confident predates the hack. Clean the site when no trustworthy backup exists and the damage is limited. Rebuild when the site is badly compromised, old or unmaintained. In all three cases, close the way in first, or the problem returns.

The hard part of restoring is knowing which backup is clean. Attackers often get in weeks before anything visible happens, so last night's backup may already contain the backdoor. If you can, compare the backup against the infected copy and look for files that should not be there. Our guide on the importance of regular data backups explains why keeping several older copies, stored away from the hosting account, makes this decision so much easier.

OptionWhen it fitsWhat to watch
Restore from a backupYou have a copy you are confident was made before the attackClose the way in first, and check the backup itself is not already infected
Clean the existing siteNo trustworthy backup, and the damage is limited to a few files or pagesHidden backdoors are easy to miss; compare every file against a known-good copy
Rebuild or migrateThe site is heavily compromised, years out of date, or nobody can maintain itKeep the same URLs or set 301 redirects so search rankings are not lost

How did the attacker get in?

Most small-business websites are not targeted personally. They are found by automated scans looking for known weaknesses: outdated plugins, themes or CMS versions, weak or reused passwords, leaked FTP or hosting credentials, and abandoned admin accounts. Finding which one applies is the step that stops a repeat.

Start with the boring causes, because they are usually the right ones. On WordPress sites, the security reports that vendors such as Patchstack publish each year consistently find most new vulnerabilities in plugins and themes, not in WordPress itself. So check the update dates of every plugin and theme, and remove anything you no longer use rather than leaving it switched off.

Then look at accounts. A password used on another site that was later breached, an FTP login sitting in an old developer's email, or an administrator account for someone who left years ago are all common doors. The access logs you copied in the first hour will often show which account was used and from where.

The hosting setup can play a part too. On some poorly isolated shared servers, one compromised site can affect its neighbours, and a host that never updates its server software leaves gaps you cannot close yourself. We covered those risks in common problems of web hosting and how they affect business websites.

What if your site looks defaced but your files were never touched?

Check your domain's DNS records. If the domain now points to a server you do not recognise, the attacker did not break into your website at all. They got into your domain registrar or DNS account and sent your visitors somewhere else. The fix then happens at the registrar, not on the server.

This is less common than a website hack, but it is worth ruling out early, because no amount of cleaning files will help. Compare the A records and nameservers against what your host gave you. If they have changed, recover the registrar account, put the records back, turn on two-factor authentication and the registrar lock, and check whether your email (MX) records were changed as well, since redirected email is how attackers reset other passwords.

If you are not sure who even holds the registrar login, that is a separate problem, and our guide on what to do when your web developer disappears walks through recovering each account in order.

How do you get Google to remove the hacked warning?

Once the site is clean and the way in is closed, open the Security Issues report in Google Search Console, confirm every listed problem is fixed, and click "Request Review" with a short note on what you did. Google rechecks the site and removes the warning if it finds nothing.

A review is not instant, and a request on a site that is still infected is rejected, which slows the next one down. So be thorough before you ask. Spam pages the attacker created should return a 404 or 410 status so Google drops them from its index over time. The Removals tool in Search Console can hide the worst URLs from results quickly, but only temporarily (about six months), so treat it as a stopgap while the real cleanup happens.

Then resubmit your sitemap and watch the Pages report for the following weeks. If legitimate pages fell out of the index during the hack, our guide on why your website isn't showing up on Google covers the indexing side.

Do you have to tell your customers about a website hack?

If the attacker could have reached personal data, such as customer accounts, order details or contact form submissions, you may have a legal duty to report it. Under the EU's GDPR, a personal data breach that is likely to put individuals' rights at risk must be reported to the supervisory authority within 72 hours of becoming aware of it.

Other countries have their own rules, and the details depend on what data was exposed and where your customers live. A brochure site with no logins and no stored forms is a very different case from an online store. If personal data was involved, get legal advice quickly, because the clock starts when you find out, not when you finish cleaning.

There is also a practical reason to tell affected customers even when the law does not require it: if your site or your email domain was used to send them phishing messages, a short honest note protects them and your reputation better than silence.

How do you stop your website being hacked again?

Keep everything updated, remove what you do not use, give every account a unique strong password with two-factor authentication, and keep recent backups stored outside the hosting account. Then make sure someone is actually watching the site, so the next problem is caught quickly.

Our view: closing the way in matters more than anything else on this list, because a site cleaned without it tends to be reinfected. Once that is done, prevention is mostly routine maintenance that nobody gets round to. If nobody in your business owns that routine, give it to someone, in writing.

The routine worth keeping:

  • Updates: CMS core, plugins and themes updated promptly, and anything unused deleted rather than deactivated.
  • Accounts: one administrator account per person, removed the day they leave, unique passwords and two-factor authentication on hosting, CMS, registrar and email.
  • Backups: daily, automatic, with several older copies kept outside the hosting account, and a restore tested now and then.
  • HTTPS everywhere: a valid SSL certificate on every page, so logins and forms are never sent unencrypted.
  • Monitoring: Google Search Console set up with alerts going to an inbox someone reads, plus uptime monitoring.
  • Hosting: a provider that keeps server software patched and isolates your site from other customers.

If your site has been hacked and you would rather not rebuild it on the same setup, our website migration and rescue service takes over existing sites, diagnoses and fixes what is broken, and moves everything to managed hosting with a free SSL certificate, automatic daily backups, DDoS protection and round-the-clock monitoring, with zero downtime and no loss of your search rankings. Tell us what you are seeing, and we will tell you what can be recovered.

FAQ

Frequently Asked Questions

What is the first thing to do when your website is hacked?

Contain it before you fix it. Take the site offline or into maintenance mode, tell your hosting provider, and copy the files, database and logs as they are. Then change every password from a device you trust and turn on two-factor authentication. Only restore or clean the site once you know how the attacker got in.

Can I just restore my website from a backup after a hack?

Yes, if the backup predates the hack and you close the way in first. Attackers often get in weeks before anything shows, so a recent backup may already contain their backdoor. If you restore without fixing the weakness they used, such as an outdated plugin or a leaked password, the site is usually reinfected.

How do I remove the "This site may be hacked" warning from Google?

Clean the site completely and close the vulnerability, then open the Security Issues report in Google Search Console and click Request Review, describing what you fixed. Google rechecks the site and lifts the warning if it finds no remaining problems. Spam pages created by the attacker should return 404 or 410.

What does it mean when a website is defaced?

Defacement means the visible content, usually the homepage, has been replaced with the attacker's own message or image. It normally means someone gained write access to the site's files or CMS. If the files look untouched, check your DNS records too, because the domain may have been pointed to a different server.

How can I protect my website from being hacked again?

Keep the CMS, plugins and themes updated, delete anything unused, and give every account a unique strong password with two-factor authentication. Keep daily backups stored outside your hosting account, remove old administrator accounts, and set up Google Search Console alerts so a new problem is noticed quickly.