evheniy / robots-txt-bundle

RobotsTxtBundle 为您的应用程序增加了生成 robots.txt 文件的功能。

安装次数: 16,367

依赖关系: 0

建议者: 0

安全性: 0

星星: 5

观察者: 2

分支: 1

公开问题: 0

类型:symfony-bundle

1.0.0 2015-11-04 14:36 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:10:43 UTC


README

此扩展包为 Symfony2 提供了 robots.txt 生成器。

knpbundles.com

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status Coverage Status Scrutinizer Code Quality Build Status

安装

$ composer require evheniy/robots-txt-bundle "1.*"

或者添加到 composer.json

"evheniy/robots-txt-bundle": "1.*"

AppKernel

public function registerBundles()
    {
        $bundles = array(
            ...
            new Evheniy\RobotsTxtBundle\RobotsTxtBundle(),
            ...
        );
        ...
...

config.yml

robots_txt:
  - 'User-agent: *'

或者使用 sitemap

robots_txt:
  - 'User-agent: *'
  - 'Sitemap: http://test.com/sitemap.xml'

最后一步

app/console robots.txt:dump

使用不同的环境

主要思路是针对不同的环境使用 robots.txt,例如:对于 dev 隐藏项目不被搜索引擎如 Google 索引

config_prod.yml:

robots_txt:
  - 'User-agent: *'
  - 'Sitemap: http://test.com/sitemap.xml'

config_dev.yml:

robots_txt:
  - 'User-agent: *'
  - 'Disallow: /'

然后运行 prod

app/console robots.txt:dump --env=prod

然后运行 dev

app/console robots.txt:dump --env=dev

或者直接

app/console robots.txt:dump

许可证

此扩展包遵循 MIT 许可协议。

俄语文档

演示

构建 robots.txt