Skip to content

Instantly share code, notes, and snippets.

@luchaninov
Last active June 28, 2018 16:00
Show Gist options
  • Save luchaninov/79d5deeac20838c1a066e1e1502428fc to your computer and use it in GitHub Desktop.
Save luchaninov/79d5deeac20838c1a066e1e1502428fc to your computer and use it in GitHub Desktop.
Fix <noindex> for Google
<!-- BEGIN FIX -->
<?php if(strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot')!==false){if(!function_exists('fixNoindex')){
function fixNoindex($buffer){return preg_replace('#<noindex>(.*?)</noindex>#msi','<!-- $1 -->',$buffer);}}ob_start('fixNoindex');} ?>
<!-- END FIX -->
<!-- THIS IS EXAMPLE -->
<!-- DON'T COPY IT TO YOUR SITE -->
Indexable, visible.
<noindex>
Non-indexable, but still visible.
</noindex>
Indexable, visible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment