nyx-solutions / yii2-nyx-robots
Yii2 Robots.txt 生成模块
5.0.0
2022-06-02 14:55 UTC
Requires
- php: >=8.1.0 <8.2
- nyx-solutions/yii2-nyx: ~5.0.0
- nyx-solutions/yii2-nyx-helpers: ~5.0.0
- nyx-solutions/yii2-nyx-mvc: ~5.0.0
README
自动生成 robots.txt 文件的 Yii2 模块。
安装
安装此扩展的首选方式是通过 composer。
- 运行以下命令之一
php composer.phar require --prefer-dist "nyx-solutions/yii2-nyx-robots" "*"
或者在您的应用 composer.json
文件的 require
部分添加以下内容
"nyx-solutions/yii2-nyx-robots": "*"
使用方法
- 配置您的应用配置文件中的
cache
组件,例如
'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], ]
- 在您的应用配置文件
modules
部分添加一个新的模块,例如
'modules' => [ 'robots' => [ 'class' => 'nyx\modules\robots\Module', 'settings' => [ 'disallowAllRobots' => false, 'allowAllRobots' => false, 'useSitemap' => true, 'sitemapFile' => '/sitemap.xml', 'robots' => [], 'allowRules' => [ 'all' => [ '/uploads' ] ], 'disallowRules' => [ 'all' => [ '/assets' ] ] ] ] ]
- 在您的应用配置文件
urlManager
部分添加一个新的规则,例如
'urlManager' => [ 'rules' => [ ['pattern' => 'robots', 'route' => 'robots/default/index', 'suffix' => '.txt'], ] ]
许可证
yii2-nyx-robots 在 BSD 3-Clause 许可证下发布。请参阅附带的 LICENSE.md
获取详细信息。