开发者

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

开发者 https://www.devze.com 2023-01-13 22:42 出处:网络
I have a particular PHP 开发者_C百科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\']?

I have a particular PHP 开发者_C百科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.


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

Here is one.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号