RSSSubscribeContact  

Join our Chrome FORUM

Chat Chrome news, tips, themes, plugins...

Free Chrome THEMES

Free download Google Chrome themes

You are here: Home > Google Chrome Tutorial

How to block Google Chrome


http://www.chromefans.org Apr 29, 2010 07:15 PDT
Image: How to block Google Chrome

I received requests from a few webmasters some time ago asking me if there was a way to block Google Chrome from their website (some websites depends on a special browser). This article shows you how you can do this in Apache or PHP.

How to block Google Chrome in Apache

Before you can block Google Chrome in Apache, you will need to know the "User Agent string" of Google Chrome. A typical example is:

Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.23 Safari/533.4

There is a User-Agent string list for all browsers.

To block Google Chrome in Apache, we should adjust the settings in httpd.conf. If you have no permission to access httpd.conf, you can create the .htaccess in the top web directory of your site.

An example of a .htaccess file with rules to block Google Chrome is as follows:

BrowserMatchNoCase Chrome CHROME
Order Deny,Allow
Deny from env=CHROME

Don't forget to restart your Apache server if you modified the httpd.conf file.

Now, when you visit your website in Google Chrome, you will get a Forbidden error:

Forbidden

You don't have permission to access xxxx.htm on this server.

How to block Google Chrome in PHP

To block Chrome in PHP is very easy, the User-Agent string is stored in global variable $_SERVER['HTTP_USER_AGENT'], we can find the keyword "Chrome" in this variable. An example is as followers:

<?php
if ( isset($_SERVER['HTTP_USER_AGENT']) )
{
  $t_bIsChrome = strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome');
  if ( $t_bIsChrome !== false)
  {
    echo "Sorry, this website isn't compatible with Google Chrome.";
    exit;
  }
}
// Do something...
?>

If you have better way to block Google Chrome, please leave your comment.

Other resource about block Google Chrome

Tags: User-agent | PHP | Apache | Block Google Chrome | Webmaster | Chrome HOW TO



#1  Bob posted on May 03, 2010 16:29 PDT
Quote:
echo "Sorry, this website isn't compatible with Google Chrome.";

Must you promote terrible website codings and lazy developers?!?

#2  nospam posted on May 28, 2010 23:27 PDT
I would bet this request comes from Mickeysoft webmasters behind (under?) their .asp.net server

Quote:
echo "Apache?!? haven't we killed them all yet, Bill?"

Total Comments: 2, Show: 2

Leave your comment
If you want to leave your comment on this article, simply fill out the next form:
Name: * Requirement
E-mail: Optional (won't be published)
Website / Blog: Optional
Are you a human? For anti spammer, please calculate following expression:
7 + 12 = * Requirement
Comment:
* Requirement
You can use these tags:
[b] Text [/b]: Bold text
[quote] Text [/quote]: Quote text