Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel middleware code to add response headers to prevent SEO indexing.
<?php
namespace App\Http\Middleware;
use Closure;
class PreventSEOIndexingHeaders
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
$response->header('X-Robots-Tag', 'none, noarchive, noimageindex');
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.