user437693
user437693

Reputation: 31

How to ignore pageviews by search engines on a PHP page?

I have a particular PHP page that I want to conditionally do things only if the visitor is not a search engine. Are there some good regex to match $_SERVER['HTTP_USER_AGENT']?

Or would it be better to do a javascript redirect back to the page but set a flag, since search engines don't have javascript? (I don't have to worry much about my users not having Javascript for this page.)

I don't want to completely exclude search engines from hitting the page though, so save the robots.txt suggestion.

Upvotes: 3

Views: 167

Answers (1)

user333306
user333306

Reputation:

You have to use a browser detection script with an up to date user agent database.

Here is one.

Upvotes: 2

Related Questions