WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#8176 closed defect (bug) (fixed)

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

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

Description

Hi,

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: *
Disallow:

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

Example here: http://www.annuaire-info.com/robots-txt/

Jean-Luc

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

comment:1 ionfish5 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.

comment:2 Jean-LucfromBrussels5 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.

DD325 years ago

comment:3 DD325 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

comment:4 ryan5 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.