Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#8176 closed defect (bug) (fixed)

page name /robots-txt/ creates confused with robots.txt

Reported by: jean-lucfrombrussels's profile Jean-LucfromBrussels Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch commit
Focuses: Cc:



I have created a page (not a post) called /robots-txt/. It is an information page about the way /robots.txt works. The real content of the page is not displayed; in fact, what is displayed is this :

User-agent: *

Addresses like /robots-txt/crawl-delay/ work correctly. What can I do to make /robots-txt/ work as well ?

Example here:


Attachments (1)

8176..diff (903 bytes) - added by DD32 15 years ago.

Download all attachments as: .zip

Change History (5)

#1 @ionfish
15 years ago

This is to do with the way that WordPress' rewrite rules work, and that it automatically generates a robots.txt file depending on the site's privacy options.

#2 @Jean-LucfromBrussels
15 years ago

Thanks ionfish,

I understand that. I reported this as a bug, because I do not think there is a good reason to confuse robots-txt with robots.txt.

I will reformulate my question: Is there a way to make WordPress rewrite robots.txt and not robots-txt ?

I changed line 808 in /wp-includes/rewrite.php in

$robots_rewrite = array('robots\.txt$' => $this->index . '?robots=1');

but this did not help.

15 years ago

#3 @DD32
15 years ago

  • Keywords has-patch commit added
  • Milestone changed from 2.8 to 2.7

but this did not help.

It would've if you cleared the Rewrite rules :)

The WordPress Rewrite rules are cached in the database, You need to clear them after making changes to the rules. Bumping the $wp_db_version up a notch will cause it to re-create them.

The attached patch is exactly what you posted, with the DB version bumped up

#4 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [9650]) Escape dot in robots rewrite rule. Props Jean-LucfromBrussels and DD32. fixes #8176

Note: See TracTickets for help on using tickets.