Search code examples
phprequest-uri

$_SERVER['REQUEST_URI'] with multiple OR


this work :

    <?php
  if ($_SERVER['REQUEST_URI'] !== '/fr/page1/'){
    echo '<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">';
  }
  ?>

(the meta tag not displayed on page 1)

but this not work :

    <?php
  if (($_SERVER['REQUEST_URI'] !== '/fr/page1/') || ($_SERVER['REQUEST_URI'] !== '/fr/page2')){
    echo '<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">';
  }
  ?>

the meta tag is displayed on both page :(

Thank you


Solution

  • || – logical OR means if one of the expressions in some_expr1 || some_expr2 || some_expr3 is evaluated to TRUE then the whole expression is evaluated to TRUE. I guess you need to change it to logical AND&&.