Skip to content

Instantly share code, notes, and snippets.

@verschuur
Created November 16, 2017 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verschuur/b816f338eeef4d134876aba69618960d to your computer and use it in GitHub Desktop.
Save verschuur/b816f338eeef4d134876aba69618960d to your computer and use it in GitHub Desktop.
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