I have to add noindex to some url’s, this is my code at the moment:
<?php if ($metanoindex) { ?>
<meta name="robots" content="noindex,follow" />
<?php } elseif ($_SERVER['REQUEST_URI']=='/dolls/1/bestselling' ) { ?>
<meta name="robots" content="noindex,follow" />
<?php } elseif ($_SERVER['REQUEST_URI']=='/dolls/1/bestselling/30' ) { ?>
<meta name="robots" content="noindex,follow" />
<?php } elseif ($_SERVER['REQUEST_URI']=='/dolls/1' ) { ?>
<meta name="robots" content="noindex,follow" />
<?php } else { ?>
<meta name="robots" content="index,follow" />
<?php } ?>
I wondered if there is a way to make an array of urls instead of repeating “else if” each time.
Try as below
PHP Manual: in_array()