execut/yii2-robots-txt

Module for generate robots.txt file by url rules

Maintainers

👁 execut

Package info

github.com/execut/yii2-robots-txt

Type:yii2-extension

pkg:composer/execut/yii2-robots-txt

Statistics

Installs: 13 474

Dependents: 1

Suggesters: 0

Stars: 7

Open Issues: 0

1.2.3 2019-05-05 22:01 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Apache-2.0 f4af054be73d926d6455784461c0c8aaaa041672

  • eXeCUT

robots.txtyii2

This package is auto-updated.

Last update: 2026-06-16 00:09:00 UTC


README

Installation

The preferred way to install this extension is through composer.

Install

Either run

$ php composer.phar require execut/yii2-robots-txt "dev-master"

or add

"execut/yii2-robots-txt": "dev-master"

to the require section of your composer.json file.

Configuration example

Add to application config folowing rules:

[
 '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' => [
 //..
 ],
 ],
 ],
 ],
 ],
 ],
 ],
];

After configuration robots.txt file is opened by /robots.txt link

License

yii2-robots-txt is released under the Apache License Version 2.0. See the bundled LICENSE.md for details.