Site maintenance middleware SEO friendly with PSR-7
Site maintenance middleware SEO friendly
Create instance of middleware as you want (we use named constructors) and add it to middleware runner.
$date = DateTime::createFromFormat('Y-m-d H:i:s', '2025-11-30 11:12:13'); $middleware = MaintenanceMiddleware::createWithRetryAsDateTime($date, $psr17ResponseFactory); $middlewareRunner->add($middleware); $middlewareRunner->run();
- Setup 503 status code,
Retry-Afterheader (as seconds or HTTP-date),
Redirectheader (redirect page after
More about this SEO practice: How to deal with planned site downtime in Google Webmaster Central Blog.
composer require php-middleware/maintenance
This package require PSR-17 message factory implementation to return SEO friendly response.