PSR-15 middleware to avoid search engine indexing with PSR-7
This middleware provide framework-agnostic possibility to preventing your site from being indexed.
- Add
X-Robots-Tag
header withnoindex, nofollow
value. - Add
robots.txt
"file" withUser-Agent: * Disallow: /
body
composer require php-middleware/block-robots
$blockRobotsMiddleware = new PhpMiddleware\BlockRobots\BlockRobotsMiddleware();
$app = new MiddlewareRunner();
$app->add($blockRobotsMiddleware);
$app->run($request, $response);
Middleware tested on:
Middleware should works with:
And any other modern framework supported middlewares and PSR-7.