Page 1 of 1

Limit max amount of pages a user can access

Posted: Sun Jan 27, 2008 8:49 am
by ripples
I'm trying to find a way to limit the amount of pages a user can access. I use a shared server so I only have access to .htaccess ; I also have PHP parse all my files.

My site has about 300 pages but sometimes my logs show "users" which look at 1000, I guess these are robots. How can I limit this to say: 100 ?

Does MaxKeepAliveRequests have anything to do with this ? Does this directive have any results when I parse all my files with PHP ? I also don't want Google to be negatively affected, so can this be achieved excluding some user-agents ?

Re: Limit max amount of pages a user can access

Posted: Sun Jan 27, 2008 12:02 pm
by Ambush Commander
MaxKeepAliveRequests doesn't have anything to do with this. Since your website is open to the general public, there's no way to foolproof limit the amount of pages a user can access. If you're not running into CPU/Bandwidth problems, I'd recommend you just not worry about it... the bots can't hurt.

Re: Limit max amount of pages a user can access

Posted: Sun Jan 27, 2008 12:28 pm
by Christopher
You could implement something using a session variable that counted page views and did not show pages after a certain count. Include something like this in every page (or in a Front Controller).

Code: Select all

<?php
session_start();
if (! isset($_SESSION['pagecount'])) {
    $_SESSION['pagecount'] = 0;
}
if ($_SESSION['pagecount'] > 100) {
    exit();
} else {
    ++$_SESSION['pagecount'];
}