web-dev-qa-db-ja.com

Robots.txtに不要な "crawl delay:10"という行が追加されました

robots.txtページにリクエストを出すと、crawl delay: 10行が追加されていることに気付きました。ファイルをダブルチェックしましたが、その行がありません。なぜ表示されるのですか。それは多分いくつかのプラグインの奇妙なふるまいですか?

3
LordSilver

自分のサイトのCMSとしてWordPressを使用している人のためには、単にrobots.txtファイルを削除し、代わりにWordPressによって生成された仮想のものを変更することによって、Webホスティングサーバーのルールを回避することができます。テーマのfunctions.phpファイルにフィルタを追加するだけです。

これがコードスニペットです。

//* Append directives to the virtual robots.txt
add_filter( 'robots_txt', 'robots_mod', 10, 2 );
function robots_mod( $output, $public ) {
    $output .= "Disallow: /wp-content/plugins/\nSitemap: http://www.example.com/sitemap_index.xml";
    return $output;
}

あなたがしなければならないのはあなた自身の指令で$出力を修正することだけです。

1
LordSilver

私のウェブサイトのために、私は同じ問題を抱えていました。

これが私のrobots.txtファイルです(「クロール遅延:10」なし)。

sitemap: https://baliradar.com/sitemap.xml
User-agent: *
Disallow: /cgi-bin/ 
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/
Disallow: /archives/
Disallow: /wp-*
Disallow: /author
Disallow: /comments/feed/
User-agent: Mediapartners-Google*
Allow: /
User-agent: Googlebot-Image
Allow: /wp-content/uploads/
User-agent: Adsbot-Google
Allow: /
User-agent: Googlebot-Mobile
Allow: /

私は私のウェブホスティングに連絡しました、そして、彼らは私にあなたの答えを確認します

0
Didz