KB Plugins

The best Wordpress plugins are free

Print this post

KB Robots.txt

When robots (like the Googlebot) crawl your site, they begin by requesting http://example.com/robots.txt and checking it for special instructions. Use this plugin to create and edit your robots.txt file from within Wordpress (using Options -> Robots.txt).

Whenever a user (or a robot, more likely) appends “robots.txt” to your blog URL (e.g. http://blog.example.com/robots.txt), this plugin will serve up the robots.txt file that you created in the Wordpress admin menu.

This plugin should work with most versions of Wordpress, but it is particularly intended for WP-MU installations, since it allows each WPMU blog to have a unique robots.txt file.

Download this plugin from the wordpress.org repository .

Limitations

Note that robots make only top-level requests for robots.txt files. If you have Wordpress installed in a subdomain or in your root, this plugin will work as intended. But if you have Wordpress installed in a subdirectory, then this plugin won’t do much for you, since the search engines won’t look for http://example.com/blog/robots.txt, only for http://example.com/robots.txt. Just to make sure this is clear,

  • Wordpress in a subdomain: http://blog.example.com/
  • Wordpress at the root: http://example.com/
  • Wordpress in a subdirectory: http://example.com/blog/

Support

If the FAQs at the download page don’t answer your questions, you can post support questions below.

21 comments »

1
Tene adds
at 2:10 am on May 3, 2007 #

Adam,
Brilliant plug in, placed a note about it in WPMU forum. WPMU doesn’t behave exactly intuitively at the blogs.dir level, and this plugin neatly sidesteps the whole issue to meet a very important requirement for subdomains and full external domains running off WPMU.
Have you considered serving a Google Sitemap using the same strategy?

2
Thus saith Adam
at 4:04 pm on May 3, 2007 #

Thanks.

I’m not sure about the Google Sitemap thing. There would need to be some sort of caching mechanism, or else large blogs would take a very long time to generate a sitemap each time. I guess people could write a sitemap by hand, but that’s not so fun.

3
Tene opines
at 1:22 pm on May 5, 2007 #

The caching could be achieved by generating the sitemap after new content is created, and storing the output in wp options - equivalent to the config text you store for robots. So when Google requests sitemap.xml, you just serve the text straight out of the table.

Maybe there is a way to queue a long running job - e.g. after updating content, launch the sitemap generation in batch mode? - that would avoid any performance hit for the author.

There is a 10Mb limit on file size - while a compressed version doesn’t seem to be mandatory, producing and storing a .gz version to support very large blogs may present issues.
https://www.google.com/webmasters/tools/docs/en/protocol.html

The reason I suggested this is that - as I read it from the wpmu forum - getting sitemaps working in WPMU means installing the plugin, pre-populating the sitemap.xml and sitemap.xml.gz (to avoid permission errors), modifying .htaccess, and modifying allowed files. Messy. Your dynamic generation solution would avoid the .htaccess mods and physical file altogether, which for WPMU installations makes a *lot* of sense.

Possibly Arne Brachold’s code (for generating the sitemap itself) would be reusable - so it might just be a matter of wrappering Arne’s map generation code within your page serving model?

4
Thus saith Adam
at 10:32 am on May 7, 2007 #

I see. Not a bad idea, but I probably won’t have time to do it.

5
Alex opines
at 8:30 pm on September 8, 2007 #

I installed this plugin and changed the robots.txt file through the interface, but nothing has changed in the actual file itself. What am I missing here? I’m not using WP-MU, just the regular Wordpress.org install.

-Alex

6
Thus saith Adam
at 9:06 am on September 9, 2007 #

I’m not sure what you mean, Alex. There isn’t any file involved here. The robots.txt gets served from your blog’s database, just like your posts do. The plugin doesn’t create or edit any files.

Incidentally, if you do have a file called robots.txt installed in your blog’s directory, then you might need to delete it for this plugin to work correctly (depending on your htaccess settings).

7
Alex exclaims
at 11:12 am on September 9, 2007 #

Thanks for the speedy reply! I’m not sure what the problem was either. I tried deleting the robots.txt file that was already there, but when I entered my changes through KB Robots in the Wordpress interface and clicked “View Robots.txt” after save the changes, none of them were reflected in what I saw. I ended manually creating the robots.txt and putting it back in the blog directory.

-Alex

8
stacey opines
at 12:49 pm on October 23, 2007 #

Hi Adam,

I installed your plugin. This what I entered in the robots.txt plugin window.
User-agent: *

Disallow:
But when I do I do [link] this is what I get, and in the plugin when it says check the the robots.txt file after I submit I get this also:
# BEGIN XML-SITEMAP-PLUGIN
Sitemap: [link]
# END XML-SITEMAP-PLUGIN

So uninstalled the google sitemap and analytics, and still the same thing. I was wondering could you help me solve this problem.

Thanks,
Stacey

9
stacey proclaims
at 6:13 pm on October 24, 2007 #

I fixed it. I wasnt putting it in the root directory.

10
Thus saith Adam
at 6:17 pm on October 24, 2007 #

Hmm. It doesn’t go in the root, it goes in the plugins folder, but if you’ve got it working, great.

11
Abhishek Singh contributes
at 8:45 am on February 19, 2008 #

Hi
I am using WP-MU. and installed your plugin. and pasted the wordpress robot text from your one of the post. but now when i want to see the robot.txt then inplace to going to [link] it goes to
[link] URl

Please help me and tell me what to do..

12
Thus saith Adam
at 10:56 am on February 19, 2008 #

I don’t know what to say. I use it on WPMU without problems. One thing I haven’t tried is using it on the root WPMU blog–I’ve only tried it on member blogs. Maybe that’s the problem. Or, it could be that your version of WPMU doesn’t support the action hook that the plugin uses. I think it’s the init hook, but I don’t remember.

Regardless, I don’t have the time to look into this at the moment, and probably won’t for several weeks. But if you’re running WPMU, you are probably familiar enough with PHP and WP to debug this fairly quickly. If you find a bug, let me know and I’ll patch the plugin. Good luck.

13
Scott remarks
at 9:05 am on July 29, 2008 #

Hi Adam,

I am writing to ask a question about your WP MU robots.txt plugin “KB Robots.txt”

It sounds great and thanks for creating it.

I am new to using WP MU and just installed it on a site of mine however, I already have a WP blog on my main domain so WP MU is in a sub-directory.

Therefore, it’s like [link] (where blogs is my WP MU install)

Since you say, “But if you have Wordpress installed in a subdirectory, then this plugin won’t do much for you, since the search engines won’t look for [link]” — does this mean it’s useless for me to install your plugin as well as even having a robots.txt file with WP MU installed in a sub-directory?

Even though I have a robots.txt for my root domain could I not somehow add robot information for my WP MU?

For example, say right now in my main root folder [link] I have a robots.txt file with User-agent: *
Allow: /

Could I not simply amend this and also put Allow: /blogs/ ?

This way my robots.txt file is in my main root folder (public_html) and the SE’s can hopefully follow on to the MU blogs??

If the answer is “yes” then should I duplicate all(most) of the instructions in my robots.txt file but add /blogs/ to each? Does that make sense? So if I had User-agent: * Allow: / I would also have Allow: /blogs/ for command?

I apologize for this long email. Just wondering if I can apply robot info to my WP MU in my sub-directory somehow :)

Thanks again

14
Thus saith Adam
at 10:22 am on July 29, 2008 #

Putting a robots.txt file into a subdirectory will not accomplish anything, so, no, the plugin won’t help you. More info:

[link]

15
gadget adds
at 9:19 am on September 10, 2008 #

Adam, from the comments above it sounds as though this is a must have plugin. I just don’t fully understand the benefits I’ll get from it though. Is there any other info I can read to understand it better? Sorry to have to ask, I’m sure you’re very busy.

16
monroe remarks
at 4:06 am on September 26, 2008 #

Hi - I need to create the robot.txt file to exclude the robots just from specific pages on the wp site rather than whole areas - like the archives. I looked at the examples you have in the plugin - I just need some clarification on how to exclude specific pages.
Thanks

17
Rami Abughazaleh adds
at 4:21 am on December 8, 2008 #

Hi.

Thank you for KB Robots.txt wordpress plugin. It works very well!

I just wanted to let you know that there is a bug:

If /wp-admin/ requires https \ ssl then firefox will complain that the submit button will transfer data in a non secure way, etc. and that is because http:// is hard-coded in kb-robots-txt.php line 59.

The fix for me was just to replace http:// with https:// however I would like the plugin to dynamically determine this from checking the php $_SERVER[’HTTPS’] variable for example.

Thank you.

18
John writes
at 3:06 pm on March 16, 2009 #

Just reporting that the plugin works flawlessly on WPMU 2.7 with subdomains - very nice job. Thanks for putting it together.

19
at 9:58 am on March 19, 2009 #

Hi Adam,

Just a quick note to say thanks for this.

-drmike

20
Jack says
at 3:56 pm on March 26, 2009 #

I’ve installed the plug-in on WP 2.7.1 and I would like to think that I’m of average intelligence but I can’t seem to figure out how to use this. I’ve went to [link] and it returns a 404 not found. I know you’re a busy man and I am checking the plug-ins documentation, thanks in advance.

21
Ken C adds
at 11:11 am on April 19, 2009 #

I was looking for a robots.txt manager plugin and looked at your limitations - and I think you are over limiting your plugin. I use wordpress in a subdirectory named wordpress. To get the robots.txt you generate to be used I tried a symbolic link in the document root - that did not work. So I added a rewrite rule to my document root .htaccess file:
# use wordpress robots.txt file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^robots\.txt$ /wordpress/robots.txt
</IfModule>

This is working great at this time. I am not a security expert - so if anyone sees a security issue with this, please let me know.

Great plugin - thanks for creating it and sharing it with everyone.

Leave a comment

Comment Guidelines
  • Yes, your comments will be visible to everybody. (Unless you use the private contact form.)
  • Allowed HTML: <a> <b> <blockquote> <cite> <code> <em> <i> <strong>
  • Code: Put code in `backticks` (above your "Tab" key) or it won't display well
  • Gravatars: To override the default image by your comment, use a gravatar
  • Links: If you include more than one link, your comment will go into the spam queue

Please read before commenting: Because my real job has me swamped at the moment, I am not supporting my plugins at this time. Sorry. This may last several weeks.

If you have a bug report, feature request, or other general feedback about a plugin, please leave a comment—but do not expect an immediate response. If you are requesting help, though, please check the plugin's documentation thoroughly rather than ask your question as a comment.

Thank you for your understanding.