From 25df5fe335210d6b59df508d8ee1b2c417f664a9 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 29 Sep 2011 21:47:04 +0000 Subject: [PATCH] Disallow indexing wp-admin and wp-includes in robots.txt. Props SergeyBiryukov. fixes #18465 git-svn-id: https://develop.svn.wordpress.org/trunk@18822 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index aaa5cc45cc..dc9a66157d 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1846,14 +1846,15 @@ function do_robots() { do_action( 'do_robotstxt' ); - $output = ''; + $output = "User-agent: *\n"; $public = get_option( 'blog_public' ); if ( '0' == $public ) { - $output .= "User-agent: *\n"; $output .= "Disallow: /\n"; } else { - $output .= "User-agent: *\n"; - $output .= "Disallow:\n"; + $site_url = parse_url( site_url() ); + $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : ''; + $output .= "Disallow: $path/wp-admin/\n"; + $output .= "Disallow: $path/wp-includes/\n"; } echo apply_filters('robots_txt', $output, $public);