nox-it/yii2-nox-robots

This package is abandoned and no longer maintained. No replacement package was suggested.

Yii2 Robots.txt Generator Module

2.0.0 2020-05-03 16:01 UTC

This package is auto-updated.

Last update: 2022-06-01 20:12:04 UTC


README

Yii2 Module for automatically generating the robots.txt file.

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock

Installation

The preferred way to install this extension is through composer.

  • Either run
php composer.phar require --prefer-dist "nyx-solutions/yii2-nyx-robots" "*"

or add

"nyx-solutions/yii2-nyx-robots": "*"

to the require section of your application's composer.json file.

Usage

  • Configure the cache component of your application's configuration file, for example:
'components' => [
    'cache' => [
        'class' => 'yii\caching\FileCache',
    ],
]
  • Add a new module in modules section of your application's configuration file, for example:
'modules' => [
    'robots' => [
        'class' => 'nyx\modules\robots\Module',
        'settings' => [
            'disallowAllRobots' => false,
            'allowAllRobots'    => false,
            'useSitemap'        => true,
            'sitemapFile'       => '/sitemap.xml',
            'robots'            => [],
            'allowRules'        => [
                'all' => [
                    '/uploads'
                ]
            ],
            'disallowRules'     => [
                'all' => [
                    '/assets'
                ]
            ]
        ]
    ]
]
  • Add a new rule for urlManager of your application's configuration file, for example:
'urlManager' => [
    'rules' => [
        ['pattern' => 'robots', 'route' => 'robots/default/index', 'suffix' => '.txt'],
    ]
]

License

yii2-nyx-robots is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.

Yii2