You are here: Home > Webmaster & Developer

How to block Google Chrome

April 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:


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:

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.";
// Do something...

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

Other resource about block Google Chrome

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

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

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

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

#3  posted on October 27, 2010 17:54 PDT
So can I do this with an iWeb site by entering some HTML code? I wanna redirect Chrome users to another site, not block. Sorry for the dumb question...

#4  posted on February 06, 2011 18:29 PST
I'm trying to redirect them, too, haven't found yet a way to do this :) Btw, Bob, not everyone likes Chrome or Google, for what it matters, so you should thank the writer for the piece of code, even though you don't use it.
If lemons like you would say bad things about everyone which has an idea, well, people will start stop thinking, I suppose, trying to avoid bad critics... and this is bad, isn't it?!

#5  posted on April 08, 2013 20:08 PDT
That code worked perfectly - Thank You!


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 x 5 + 1 = * Requirement
* Requirement
You can use these tags:
[b] Text [/b]: Bold text
[quote] Text [/quote]: Quote text