evheniy / robots-txt-bundle
RobotsTxtBundle 为您的应用程序增加了生成 robots.txt 文件的功能。
1.0.0
2015-11-04 14:36 UTC
Requires
- php: >=5.3.0
- symfony/symfony: >=2.3
Requires (Dev)
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2024-09-28 18:10:43 UTC
README
此扩展包为 Symfony2 提供了 robots.txt 生成器。
安装
$ 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 许可协议。