Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php-middleware/block-robots
Middleware to avoid search engine indexing with PSR-7 using robots.txt and X-Robots-Tag
https://github.com/php-middleware/block-robots
google middleware psr-15 psr-7 robots-txt seo
Last synced: about 2 months ago
JSON representation
Middleware to avoid search engine indexing with PSR-7 using robots.txt and X-Robots-Tag
- Host: GitHub
- URL: https://github.com/php-middleware/block-robots
- Owner: php-middleware
- License: gpl-2.0
- Created: 2015-09-02T18:13:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T20:08:16.000Z (over 3 years ago)
- Last Synced: 2024-07-31T18:15:19.328Z (4 months ago)
- Topics: google, middleware, psr-15, psr-7, robots-txt, seo
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-http - php-middleware/block-robots
README
# block-robots middleware [![Build Status](https://travis-ci.org/php-middleware/block-robots.svg?branch=master)](https://travis-ci.org/php-middleware/block-robots)
PSR-15 middleware to avoid search engine indexing with PSR-7This middleware provide framework-agnostic possibility to preventing your site from being indexed.
## How it works?
* Add `X-Robots-Tag` header with `noindex, nofollow` value.
* Add `robots.txt` "file" with `User-Agent: * Disallow: /` body## Installation
```bash
composer require php-middleware/block-robots
``````php
$blockRobotsMiddleware = new PhpMiddleware\BlockRobots\BlockRobotsMiddleware();$app = new MiddlewareRunner();
$app->add($blockRobotsMiddleware);
$app->run($request, $response);
```## It's just works with any modern php framework!
Middleware tested on:
* [Expressive](https://github.com/zendframework/zend-expressive)Middleware should works with:
* [Slim 3.x](https://github.com/slimphp/Slim)And any other modern framework [supported middlewares and PSR-7](https://mwop.net/blog/2015-01-08-on-http-middleware-and-psr-7.html).