mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
#43590: Use robots meta tag to better discourage search engines.
This changes the "discourage search engines" option to output a `noindex, nofollow` robots meta tag. `Disallow: /` is removed from the `robots.txt` to allow search engines to discover they are requested not to index the site. Disallowing search engines from accessing a site in the `robots.txt` file can result in search engines listing a site with a fragment (a listing without content). Props donmhico, jonoaldersonwp. Fixes #43590. git-svn-id: https://develop.svn.wordpress.org/trunk@45928 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1582,6 +1582,8 @@ function do_feed_atom( $for_comments ) {
|
||||
* Displays the default robots.txt file content.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 5.3.0 Remove the "Disallow: /" output if search engine visiblity is
|
||||
* discouraged in favor of robots meta HTML tag in wp_no_robots().
|
||||
*/
|
||||
function do_robots() {
|
||||
header( 'Content-Type: text/plain; charset=utf-8' );
|
||||
@@ -1595,14 +1597,11 @@ function do_robots() {
|
||||
|
||||
$output = "User-agent: *\n";
|
||||
$public = get_option( 'blog_public' );
|
||||
if ( '0' == $public ) {
|
||||
$output .= "Disallow: /\n";
|
||||
} else {
|
||||
$site_url = parse_url( site_url() );
|
||||
$path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : '';
|
||||
$output .= "Disallow: $path/wp-admin/\n";
|
||||
$output .= "Allow: $path/wp-admin/admin-ajax.php\n";
|
||||
}
|
||||
|
||||
$site_url = parse_url( site_url() );
|
||||
$path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : '';
|
||||
$output .= "Disallow: $path/wp-admin/\n";
|
||||
$output .= "Allow: $path/wp-admin/admin-ajax.php\n";
|
||||
|
||||
/**
|
||||
* Filters the robots.txt output.
|
||||
|
||||
Reference in New Issue
Block a user