如何为 WordPress 设置 robots.txt 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17029811/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:15:45  来源:igfitidea点击:

How to set up robots.txt file for WordPress

wordpressrobots.txt

提问by mAsT3RpEE

[UPDATE 2013]

[2013 年更新]

I can't find an authoritative page with a format for robots.txt file for WordPress. I promise to maintain one on my site but I want one here on stack overflow.

我找不到具有 WordPress 的 robots.txt 文件格式的权威页面。我保证在我的网站上维护一个,但我想要一个堆栈溢出。

If you know what your doing please check current draft here:

如果您知道自己在做什么,请在此处查看当前草稿:

http://mast3rpee.tk/?p=127

http://mast3rpee.tk/?p=127

Everyone else comment on this:

其他人对此发表评论:

robots.txt

机器人.txt

User-agent: *
Disallow: /cgi-bin/
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/plugins/
Disallow: /wp-content/cache/
Disallow: /wp-content/themes/
Disallow: /trackback/
Disallow: /feed/
Disallow: /comments/
Sitemap: http://domain.com/sitemap.xml
Crawl-delay: 4

回答by Waqas Ahmad

User-agent: *
Allow: /
Disallow: /cgi-bin
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content
Disallow: /e/
Disallow: /show-error-*
Disallow: /xmlrpc.php
Disallow: /trackback/
Disallow: /comment-page-
Allow: /wp-content/uploads/

User-agent: Mediapartners-Google
Allow: /

User-agent: Adsbot-Google
Allow: /

User-agent: Googlebot-Image
Allow: /

User-agent: Googlebot-Mobile
Allow: /

Sitemap: http://yoursite.com/sitemap.xml

I think this code is very authentic for robots.txt file, Just go to Public_HTML and create file with robots.txt and paste above code. You can make in your Notepad, just copy above code and paste into notpad but remember file name should robots.txt and upload to your public_HTML.

我认为这段代码对于robots.txt文件非常真实,只需转到Public_HTML并使用robots.txt创建文件并粘贴上面的代码即可。您可以在记事本中制作,只需复制上面的代码并粘贴到记事本中,但记住文件名应为 robots.txt 并上传到您的 public_HTML。

回答by kdev

As with all things SEO, things change. I think that the current advice is to have a a very minimal robots.txt file.

与所有搜索引擎优化一样,事情会发生变化。我认为当前的建议是拥有一个非常小的 robots.txt 文件。

Ignoring wp-admin, wp-includes, wp-content, etc. may prevent Google from rendering pages correctly, which it doesn't like.

忽略 wp-admin、wp-includes、wp-content 等可能会阻止 Google 正确呈现它不喜欢的页面。

Check out this article by Yoast: https://yoast.com/wordpress-robots-txt-example/.

查看 Yoast 的这篇文章:https://yoast.com/wordpress-robots-txt-example/ 。

回答by Dan Knauss

It's not safe to block much in your robots.txtnowadays single Google tries to load all assets to determine "mobile friendliness." At minimum you can block /wp-admin. Here's a more detailed, current answer to the question at the StackExchange forum for WordPress.

robots.txt当今的单一 Google 尝试加载所有资产以确定“移动友好性”时,阻止太多是不安全的。您至少可以阻止 /wp-admin。这是StackExchange 论坛上针对 WordPress 的问题的更详细的最新答案

回答by Muhammad Zaid

Create in notepad robots.txt and upload it to public_html in CPANEL .

在记事本 robots.txt 中创建并上传到 CPANEL 中的 public_html 。

*remember rename your file notepad to robots before you upload it to public_html

*记得在将文件记事本上传到 public_html 之前将其重命名为 robots