execut / yii2-robots-txt
基于URL规则的生成robots.txt文件的模块
1.2.3
2019-05-05 22:01 UTC
Requires
- yiisoft/yii2: @dev
This package is auto-updated.
Last update: 2024-09-15 20:07:48 UTC
README
安装
建议通过 composer 安装此扩展。
安装
运行以下命令
$ php composer.phar require execut/yii2-robots-txt "dev-master"
或者在您的 composer.json
文件的 require
部分添加以下内容:
"execut/yii2-robots-txt": "dev-master"
to the require section of your composer.json file.
配置示例
将以下规则添加到应用程序配置中
[ 'components' => [ 'urlManager' => [ 'rules' => [ ['pattern' => 'robots', 'route' => 'robotsTxt/web/index', 'suffix' => '.txt'], ] ] ], 'modules' => [ 'robotsTxt' => [ 'class' => 'execut\robotsTxt\Module', 'components' => [ 'generator' => [ 'class' => \execut\robotsTxt\Generator::class, 'host' => 'localhost', 'sitemap' => 'sitemap.xml', //or generate link through the url rules 'sitemap' => [ 'sitemapModule/sitemapController/sitemapAction', ], 'userAgent' => [ '*' => [ 'Disallow' => [ 'noIndexedHtmlFile.html', [ 'notIndexedModule/noIndexedController/noIndexedAction', 'noIndexedActionParam' => 'noIndexedActionParamValue', ] ], 'Allow' => [ //.. ], ], 'BingBot' => [ 'Sitemap' => '/sitemapSpecialForBing.xml', 'Disallow' => [ //.. ], 'Allow' => [ //.. ], ], ], ], ], ], ], ];
配置后,robots.txt文件将通过/robots.txt链接打开
许可证
yii2-robots-txt 采用Apache License Version 2.0发布。有关详细信息,请参阅捆绑的LICENSE.md
文件。