Limit number of visitors online

How would I go about limiting the number of visitors on a website? Like, say I want the maximum people online to be 10, and if a person enters the site while there are already ten other people viewing the site, he will be redirected to a temporary page until there is room for more visitors.

Does anyone have any information on how I would do this? Your help is greatly appreciated.

A quick search of the wiki ( turned up this page:

On it is the entry that needs to be added to the .htaccess file that limits the number of users. Now, it’s important to note that I believe that an error message will be displayed when the “extra” person tries to connect. But you might be able to set things up specially.


If you are familiar with PHP, you can also create a couter. When the counter reaches certain number, direct the user to a temporary page.

I believe you can find codes of php counter in the internet.

To redirect, you can use PHP header. remember to put it before html header

Save [color=#CC0000]$97[/color] (max discount) on dreamhost by using promo code: [color=#CC0000]97CRAZY[/color].

What kind of counter would this be? A counter that keeps track of visitors online or something like total/daily hits?

Thank you. I didn’t think to check their Wiki. I was expecting something a bit more compliacted.

If I understand you correctly, it will be something like today/daily hits.

It means the counter tracks how many users have come to your site today. Once it reaches the limit, redirect to the temp page

Save [color=#CC0000]$97[/color] (max discount) on dreamhost by using promo code: [color=#CC0000]97CRAZY[/color].

I see. Well, what I’m looking is more of a way to prevent too many people being on the website at the same time.

That’s what I thought you were looking for. That’s why I pointed you to the wiki as it references limiting “Concurrent” users.


What if someone wanted to limit a number of users to a page for a contest and once the tenth unique visitor has visited the page, the page gives them a thanks for playing message or redirects them to another.

Would anyone know how to do that?

That would require some programming, such as PHP, and a way to store access counts (files or DB) or a way to parse the access logs (less reliable since they are only kept for a week).

It only takes a few lines of code to make a very simple counter. In fact, you could even modify one of the many examples of the rating scripts. You know the kind where someone clicks on the number of stars to rate something, and the script takes the value of the click, adds it to the previous clicks, and returns the average? Just change that to add a number each time a page is visited or vote is counted.