If you search Google for your website’s name and results from your domain appear that you do not remember creating, with titles about cheap products, illegal downloads or betting, you probably have doorway pages. They are pages made by an attacker to appear in search results under your domain and send visitors elsewhere. You do not see them when browsing your website, they do not appear in the dashboard or are hidden, but Google knows about them.
The name comes from the fact that they act as a door to another place. The visitor arrives looking for something, lands on your domain and, as soon as they click or wait a few seconds, is sent to the attacker’s website. They exploit your domain’s good reputation with search engines, and while they are there, your reputation deteriorates.

In this article you will see exactly what doorway pages are and how they differ from other spam pages, how to detect them from Search Console, with requests and in the database, where an attacker can create them, how to remove them without leaving traces, how to notify Google and how to prevent them from returning. At the end there are the commands and the server rules.
What doorway pages are on a hacked WordPress site
Doorway pages and search engine entry pages
A doorway page is a page created to rank in search engines for certain words, and which redirects the visitor to another destination. It does not aim to be useful. It has text full of keywords, often generated automatically, and code that, on loading, sends the person to the shop, casino or scam the attacker wants to promote.
They are usually created by the hundreds or even thousands, each with a different title and address, to cover many searches. The attacker does not need them to be attractive, only for Google to index them.
Doorway pages compared with other types of SEO spam
They are very similar to general SEO spam, and share some causes and solutions, but they have one key difference. In general SEO spam, the content is the product and it stays on your website. With doorway pages, the page is only bait, and what matters is the destination it redirects to. That is why they usually have little real content and a lot of redirect code.
Security companies that publish malware removal guides, such as SiteLock, explain that malicious redirects take visitors to spam or scam pages, and that they are part of the same type of attack as injected pages.

Doorway pages in Google results
If you search with the site operator followed by your domain and words such as buy or cheap, you will see those that Google has indexed. These pages usually appear with an eye-catching title and short text. Sometimes, when clicking from Google, the visitor is redirected, and if you do it yourself from home while logged in, nothing may happen.
That difference in behaviour is what makes them hard to see. The attacker programs the redirect so that it only acts on visitors coming from search engines and not on the owner.
How to detect doorway pages
Search Console indexing reports
The most reliable source is Search Console. In the indexed pages report and the performance report you will see the addresses and the searches they appear for. Look for queries that have nothing to do with your website. If a cookery blog appears for watch searches, something is wrong.
The security issues report may warn of hacked content and show examples of affected addresses. Those samples are a good starting point for finding the pattern of the rest. If they all begin the same way, for example with buy or shop, you already have the rule to locate them and remove them all in one go.
Keep a list of the addresses before deleting anything. It will help you check afterwards that they return the correct code and ask Google to forget them.
Compare the number of indexed pages with the number you know your website has. A difference of thousands is almost always an attack.

Different responses depending on the browser identifier
A suspicious address can be tested with a command-line tool that identifies itself in several ways. As a normal browser, as Google’s robot, as a mobile phone. If the response changes, it is a page with conditional behaviour. A difference in the size of the response, in the title or in the redirect headers is the evidence you are looking for.
Do this with several addresses from the list, not just one, because the attacker sometimes leaves a normal page to throw you off and only the rest redirect.
Also test with and without a referrer, simulating arrival from a search engine. Some doorway pages only redirect those coming from Google, and not those who type the address directly.
Googlebot visits in the access logs
The server logs show the Google robot’s visits to addresses that are unfamiliar to you. If you see the robot requesting hundreds of addresses with similar names, such as a repeated prefix, those are doorway pages. The naming pattern will help you remove them all at once afterwards. Count how many distinct addresses the robot visits per day, because a number far higher than your real pages is another clear sign that pages exist that you do not know about.
Unusual posts and content types in the database
Count the posts by type and status, and look for spikes in creation. Also look for posts with sales or betting titles or with links to other domains. In a query sorted by creation date, doorway pages usually appear grouped within a few days.

Where doorway pages are generated
Doorway pages stored as posts
The simplest way for the attacker is to insert posts or pages into the database, with a published status. They are displayed like any other, with their own address. Some are hidden from the dashboard by manipulating the type or the author, which is why you do not see them in the normal list.
Doorway pages as HTML or PHP files
At other times the attacker uploads files to the server, in a folder of the website, with names similar to real pages. They are code or HTML files that are served directly, without going through WordPress. That is why they do not appear in the dashboard or in the database, and can only be found by looking at the files.
One clue is the modification date. Core and plugin files have similar dates, those of the latest update, and a file with a very different or very recent date stands out. A search for files modified in the last few days lists them in seconds.
Look for recent files outside the usual folders, especially in the root and in folders with generic names. Compare the core and plugins with the official versions and review the must-use plugins.
Pages generated on the fly by a script
The most sophisticated variant is a script that stores no pages at all, but generates them on demand. When someone requests an address that does not exist and whose name follows a pattern, the script invents the page. That is why there is nothing to delete, only the script that generates them.
To find it, look for code that reads the requested address and returns content for addresses WordPress does not know. It is usually in the server rules, in a hidden plugin or in the theme’s functions file.

How to remove doorway pages without leaving traces
First, make a copy of the website. Then, remove the source. Delete the script or plugin that generates the pages, the posts inserted into the database and the physical files. Do it in batches, move the posts to the bin first and check that everything is still fine before deleting them permanently.
Next, close the door the attacker came in through. Update everything, remove what you do not use, change the passwords and regenerate the security keys. If you do not, the pages will be created again.
If there were many pages, do it in two phases. First return the correct code for the addresses on the list, and a week later compare the indexed pages report with the one you had before. That way you can check that Google has understood the message.
Finally, make the deleted addresses respond with the code indicating that they no longer exist, the 410, with a server rule based on the pattern you have identified. Do not redirect them to the home page, because Google will interpret it as an attempt to divert traffic.

Removing doorway pages from the index
Once the pages no longer exist, Google will take time to forget them. You can speed up the process by submitting a clean sitemap, using the temporary removal tool for the most visible addresses and asking for the legitimate pages to be crawled again.
Monitor the indexed pages report for a few weeks. You will see the number of spam addresses fall. If some are still there after a month, check that they respond with the correct code and that no rule blocks them for the robot.
If your website had a security warning, request a review once you are sure everything is clean, explaining what you have done.
Preventing new doorway pages
Doorway pages return if the cause remains open. Keep everything up to date, use long passwords with a second factor, limit the number of administrators and watch for new posts or new files appearing. An alert that reaches you when many posts are created in a single day detects the attack within hours.
Review Search Console every few weeks, and search Google for your domain with spam words, preferably from a private window so that the search engine does not personalise the results. It is a two-minute check that detects the problem before it damages your reputation.

And keep a clean, recent backup, so that you can go back within minutes if the problem returns.
Write down in a document the pattern of the pages you found, their date and how you removed them. If the attack recurs, that note will save you hours, and if someone else works on the website, they will know exactly what to look for. If the doorway pages run into the thousands, a WordPress emergency service can remove them and close the entry point quickly.
Queries and rules to locate and close doorway pages
Testing an address with several identifiers
These Linux commands, which run in a terminal, request a suspicious address on your website identifying themselves in different ways and show the beginning of each response, to see whether it changes. Replace the address with one of your own.
# Check a suspicious address with different identifiers
for ua in "Mozilla/5.0 (Windows NT 10.0)" "Googlebot/2.1 (+http://www.google.com/bot.html)" "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)"; do
echo "== $ua"
curl -sL -m 15 -o /dev/null -w "%{http_code} %{size_download} bytes %{url_effective}\\n" -A "$ua" -e "https://www.google.com/" "https://yourdomain.com/buy-something-cheap/"
doneCounting the robot’s visits to unusual addresses
This command goes through the access logs and counts the addresses the Google robot visits, sorted, to reveal repeated patterns.
zcat -f /var/log/nginx/yourdomain.access.log* | grep -i "Googlebot" | awk '$9 == 200 {print $7}' | cut -d'?' -f1 | sort | uniq -c | sort -rn | head -40Counting posts by type and status
WP-CLI is the WordPress command-line tool. These commands count the published posts and pages and group them by type and status, to detect disproportionate figures.
wp post list --post_type=page,post --post_status=publish --format=count
wp db query "SELECT post_type, post_status, COUNT(*) AS n FROM wp_posts GROUP BY post_type, post_status ORDER BY n DESC"
wp db query "SELECT DATE(post_date) AS day, COUNT(*) AS n FROM wp_posts WHERE post_type IN ('post','page') AND post_status='publish' GROUP BY day ORDER BY n DESC LIMIT 10"
wp db query "SELECT post_author, COUNT(*) AS n FROM wp_posts WHERE post_type IN ('post','page') GROUP BY post_author ORDER BY n DESC"Listing the candidate posts
These queries show posts with a non-existent author or created in bulk, with their ID, address and title, so that you can review them before touching anything.
wp db query "SELECT ID, post_name, LEFT(post_title, 60) AS title, post_date FROM wp_posts WHERE post_status='publish' AND post_type IN ('post','page') ORDER BY post_date DESC LIMIT 30"
wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_status='publish' AND post_content REGEXP 'viagra|cialis|casino|replica|payday|bet365|essay|buy cheap'"410 response in Apache for doorway pages
This rule goes in the Apache rules file and returns a 410 for all addresses that follow the pattern you have identified. Replace the pattern with your own.
# Apache, based on the identified pattern
RedirectMatch 410 ^/(buy-[a-z0-9-]+|shop-[a-z0-9-]+)/?$410 response in Nginx for doorway pages
This is the equivalent rule for Nginx, which goes in the site configuration and returns a 410 for the same address pattern.
location ~ ^/(buy-[a-z0-9-]+|shop-[a-z0-9-]+)/?$ { return 410; }
0 comments
Add context, experience or useful nuance. Let us keep the conversation clear and helpful for whoever arrives later.