how to

How to edit robots.txt in WordPress

the short answer

WordPress generates a virtual robots.txt automatically, so to control it you either create a real file at your site root via FTP or your host file manager, or edit the rules through an SEO plugin like Yoast or Rank Math.

If you go looking for robots.txt in your WordPress install, you will probably not find it. That is not a bug. By default WordPress generates a virtual robots.txt on the fly, served at yoursite.com/robots.txt, without ever writing a file to disk. You can see it in a browser, but there is nothing to open in your file manager. This trips up a lot of people who try to edit a file that does not physically exist.

The good news is that overriding it is straightforward once you understand the rule WordPress follows: if a real robots.txt file exists at your site root, WordPress stops generating the virtual one and serves your file instead. So you have two clean paths. Drop a real file at the root, or let an SEO plugin manage the rules for you. Either way, you can paste in a clean, standards-compliant set, such as one generated by robot.guard, that whitelists search engines and blocks the AI scrapers you do not want training on your content.

~43%share of all websites built on WordPress, per W3Techs (2024)

Why there is no physical robots.txt file

When a request comes in for /robots.txt, WordPress intercepts it through the do_robots hook and prints a small default set: it disallows /wp-admin/ while allowing /wp-admin/admin-ajax.php, and appends a sitemap line. Because this output is generated at request time, no file is stored anywhere on your server. That is why FTP and your host file manager show nothing at the root even though the URL returns content.

This matters because the moment a real file appears at the document root, WordPress yields to it completely. Your physical robots.txt takes over and the virtual defaults vanish. So the question is never how to edit the invisible file, but how to replace it, either by creating a real one or by hooking into the generator through a plugin that rewrites the virtual output for you.

Option A: a real file via FTP or host file manager

The most direct method is to upload a real robots.txt to your site root, the same folder that holds wp-config.php and the wp-content directory. Connect with an FTP client such as FileZilla, or open the file manager in your hosting control panel. Create a new file named exactly robots.txt, all lowercase, and place it at the root, not inside wp-content or a subfolder. WordPress only defers to a file served from yoursite.com/robots.txt.

Paste your rules in, save, then visit yoursite.com/robots.txt in a private browser window to confirm your content is showing rather than the old default. If you generated your rules with robot.guard, you simply download the file and upload that exact file, or open it and copy its contents into the new file. Keep the Disallow for /wp-admin/ and the Allow for admin-ajax.php so plugins that rely on AJAX keep working, and keep your sitemap line so search engines can still find it.

Option B: an SEO plugin like Yoast or Rank Math

If you would rather not touch FTP, both Yoast SEO and Rank Math include a robots.txt editor. In Yoast, go to Yoast SEO, then Tools, then File editor, and you will see a Create robots.txt button or an existing editable field. In Rank Math, open Rank Math, then General Settings, then Edit robots.txt. These editors write or manage the served file for you, so the result is the same as Option A without leaving the dashboard. Note that if a physical robots.txt already exists at the root, some plugins will detect it and ask you to edit that file directly instead.

Whichever editor you use, paste your full rule set in, save, and verify the live URL. A robot.guard set is a clean fit here: build your config in the editor, toggle on the search bots you want to keep, switch on blocks for the AI scrapers from the maintained list, preview it live, then copy the generated text straight into the plugin field. Blocking AI crawlers like GPTBot or CCBot here does not affect your Google ranking, because Googlebot is a separate user-agent that you leave allowed.

how it works

  1. 01

    Check what you have now

    Visit yoursite.com/robots.txt in your browser. If you see rules but find no file over FTP, you are looking at the WordPress virtual file.

  2. 02

    Generate your rules

    In robot.guard, whitelist search bots (Googlebot, Bingbot), toggle on blocks for AI scrapers (GPTBot, ClaudeBot, CCBot, Google-Extended, and others), and add any custom rules. Preview, then download the file.

  3. 03

    Pick a method

    Use FTP or your host file manager to upload a real robots.txt to the site root, or use an SEO plugin editor in Yoast or Rank Math.

  4. 04

    Place or paste the rules

    Upload the downloaded file to the root, or copy its contents into the plugin's robots.txt field, then save.

  5. 05

    Keep WordPress essentials

    Make sure your file still disallows /wp-admin/, allows /wp-admin/admin-ajax.php, and lists your sitemap URL.

  6. 06

    Verify live

    Open yoursite.com/robots.txt in a private window and confirm your rules show instead of the old virtual defaults.

frequently asked

Why can't I find robots.txt in my WordPress files?
Because WordPress serves a virtual robots.txt generated at request time rather than a stored file. It exists at the URL but not on disk. To control it, create a real file at the root or use an SEO plugin editor.
Will a real file override the WordPress default?
Yes. As soon as a physical robots.txt exists at your site root, WordPress stops generating its virtual version and serves your file instead. There is no extra setting to toggle.
Does blocking AI bots in robots.txt hurt my Google ranking?
No. AI scrapers like GPTBot and CCBot use different user-agents from Googlebot. Disallowing them leaves Googlebot allowed, so your search visibility is unaffected.
Should I keep the /wp-admin/ rule?
Yes. Keep Disallow: /wp-admin/ with Allow: /wp-admin/admin-ajax.php so that plugins and themes relying on AJAX continue to function while your admin paths stay out of crawl indexes.

Last updated June 9, 2026

ready to try robot.guard?

start guarding your site