简体   繁体   中英

Redirect query string to 404.php

Our sitemap got corrupted and Google listed all pages with the additional text ,0.8,daily .
Example: .php?pg=8,0.8,daily

How do we get these links to redirect to, or return a, 404 ?

    if( 8 == substr($_GET['pg'],0,1) )
    {
      header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
      die();
     }

if you want to 404 for any pg being set

if( isset($_GET['pg']) )
{
  header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
  die();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM