noindex meta element via PHP on any page with HTTP query?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

noindex meta element via PHP on any page with HTTP query?

Post by JAB Creations »

I want my site to play nice with search engines and thus I don't want search engines to recrawl the same pages with HTTP queries. So what would be a nice clean way to determine if the page was loaded with any HTTP query so I can simply echo a meta noindex element?

Here is an attempt that didn't work...

Code: Select all

$thisurl = $_SERVER['REQUEST_URI'];
 if (preg_match("/?/", $thisurl)) {echo 'HTTP Query detected!';}
 else {echo 'no HTTP query detected';}
deadoralive
Forum Commoner
Posts: 28
Joined: Tue Nov 06, 2007 1:24 pm

Post by deadoralive »

Are you trying to detect if any querystring parameters have been used? Why not just

if( !empty($_GET) )
{
// do stuff here
}
Post Reply