Created
November 16, 2017 15:55
-
-
Save verschuur/b816f338eeef4d134876aba69618960d to your computer and use it in GitHub Desktop.
Laravel middleware code to add response headers to prevent SEO indexing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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