deindexwebsites.com

Scope: staging, subdomains, directories

Removing a Directory or Section of a Site From Google

Sometimes only part of a site should disappear: a legacy blog, a discontinued product line, a members area. Directory-level removal needs the signal applied by path and the removal filed by prefix.

By the deindexwebsites.com editorial team · Updated

What counts as a directory

Search engines do not know about folders in your file system. They see URLs. A "directory" is just a set of URLs that share a path prefix, such as everything beginning /old-blog/. That is exactly how the Removals tool treats it, and how you should scope the permanent signal.

Pick the permanent signal by purpose

PurposeSignalNotes
Content is gone410 or 404 for the path patternBest for retired sections
Content still useful to visitorsNoindex via header for the pathVisitors keep access
Content moved elsewhere301 each URL to its counterpartNot a deindexing task
Content privateAuth on the pathPair with removals for speed

Applying noindex to a path

Header-based rules are the cleanest because they cover all file types under the path. In NGINX, a location /old-blog/ block can add add_header X-Robots-Tag "noindex" always;. In Apache you can wrap a Header set X-Robots-Tag "noindex" inside a <Location "/old-blog/"> block or use .htaccess in that directory. The Google robots meta tag documentation confirms that site-wide and file-pattern rules can be set this way. If you use a CMS, a category-level SEO setting may handle HTML pages but not attachments, so check PDFs and images separately.

Applying 410 or 404 to a path

For a retired section, serve a real error status for every URL under the prefix, including URLs that never existed but were linked. In NGINX a location /old-blog/ { return 410; } does it in one line. Do not serve a styled message with a 200 status; Search Console reports that as a soft 404 and the pages may linger. Also avoid redirecting every old URL to the homepage, which Google can treat the same way.

Filing the prefix removal

  1. Open Removals in the property that covers the path.
  2. New request, Temporarily remove URL, choose Remove all URLs with this prefix.
  3. Enter the exact path with a trailing slash, for example https://example.com/old-blog/.
  4. Submit. According to Search Console Help the prefix covers www/non-www and http/https variants of that path.

Pay attention to the prefix boundary. A prefix of https://example.com/blog (no slash) matches /blog-news/ and /blogging-tips as well. Enter the trailing slash unless you intend the wider match, and test by reviewing the live URLs that would match. Over-matching is an easy way to hide pages you meant to keep, and it is hard to notice because the tool reports only what you submitted.

Find everything in the directory

Do not trust memory. Build an inventory:

  • Your sitemap files
  • The Pages report in Search Console, filtered by URL containing the path
  • A crawl of the site with a crawler of your choice, including links to the section
  • Server logs, for URLs that bots and users request
  • A site:example.com/old-blog/ search for a rough view (it is not exhaustive)

Make sure you also catch parameterised versions and alternate paths such as /index.php?section=old-blog that serve the same content.

Clean up inbound references

A directory that is still linked internally keeps being recrawled, which is helpful for noindex (Google reads it sooner) but a problem if you are retiring the section for good. Decide which:

  1. If you rely on noindex, leave internal links and the sitemap in place until pages drop out, then remove them.
  2. If you are returning 410, remove navigation links promptly so users do not hit errors, and drop the URLs from the sitemap.

Partial removal pitfalls

  • Template bleed: a noindex applied to a shared layout can spread to unrelated sections.
  • Canonical conflicts: pages elsewhere that use a canonical to a URL inside the removed directory.
  • Internal search pages that list the removed content.
  • Redirect rules that catch everything under the path and send it to the section index.
  • Wrong property: removal filed in a different hostname property than the one that serves the path.

Verify

Use site: checks restricted to the path, then run URL Inspection on a sample. The target statuses are excluded by noindex or not found (404). Mark your calendar for the end of the six-month window and check again.

Example: retiring a product line

A retailer discontinues a category at /legacy-gadgets/, with about four hundred product pages. A few have good inbound links and a replacement product. The team redirects those to the replacements, serves 410 for the remaining pages with a single location rule, removes the category from navigation and the sitemap, and files a prefix removal for /legacy-gadgets/. They then watch the Pages report: redirects appear under the redirect reason and the rest under not found. A search for a discontinued model number a month later returns only a forum post by a third party, which the retailer cannot control.

Path-scoped rules at a glance

ServerScope syntaxExample use
NGINXlocation /legacy-gadgets/ { ... }410 or header
Apache<Location> or .htaccess in the folderHeader or gone
CDN rulesPath match conditionHeader or response override

Frequently asked questions

Does a prefix removal work for one folder only?

Yes, it covers URLs beginning with the exact path you enter, so include the trailing slash if you want only that folder.

Will removing a directory affect pages that link to it?

Not their indexing, but broken or noindexed links reduce value passed through them, and users may hit errors if you do not update navigation.

Is noindex or 410 better for a retired section?

If the content is truly gone, 410 or 404 is the honest signal. If you want it kept but unlisted, use noindex.

Can I use robots.txt to block the directory?

Only after pages have dropped out. Blocking first prevents Google from reading noindex or seeing the 410.

Official sources

Keep reading