From a3d0926168139966583b6e1f200d47e26ff9cd15 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 28 Apr 2010 06:37:15 +0000 Subject: [PATCH] Don't serve dynamic robots.txt when WP is not installed at the root of a domain. props solarissmoke, fixes #13115 git-svn-id: https://develop.svn.wordpress.org/trunk@14273 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/rewrite.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 2274982a2f..d193f53a85 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -1564,10 +1564,11 @@ class WP_Rewrite { if ( empty($this->permalink_structure) ) return $rewrite; - // robots.txt - $robots_rewrite = array('robots\.txt$' => $this->index . '?robots=1'); - - //Default Feed rules - These are require to allow for the direct access files to work with permalink structure starting with %category% + // robots.txt -only if installed at the root + $home_path = parse_url( home_url() ); + $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); + + // Default Feed rules - These are require to allow for the direct access files to work with permalink structure starting with %category% $default_feeds = array( '.*wp-atom.php$' => $this->index . '?feed=atom', '.*wp-rdf.php$' => $this->index . '?feed=rdf', '.*wp-rss.php$' => $this->index . '?feed=rss',