Question: Google has cached some old URLs to pages that no longer exist on a site. I'd like to redirect any 404 pages to the home page.

I have a jetty installation with a ROOT.war file installed in jetty/webapps. The ROOT.war file contains a WEB-INF/web.xml file that has the following in it:

```
<error-page>
    <error-code>404</error-code>
    <location>/</location>
</error-page>

```

However, this is only redirecting top level files, nothing in subdirectories. So the following URL get redirected to the home page:

```
http://mysite.com/pageDoesntExist.html

```

But this one doesn't and just gives a 404 error:

```
http://mysite.com/directoryDoesntExist/pageDoesntExist.html

```

Is there a way to configure all 404's to go to the home page? Can I do this in the jetty/contexts directory somehow?

Answer: 
The basic query would be:

```
select user_id, count(user_id) as cnt
from yourtable
group by user_id
order by cnt desc 

```

To display the results, something like:

```
$results = array()
while($row = mysql_fetch_assoc($query_result)) {
   $results[] = "{$row['user_id']} ({$row['cnt']})"
   // repeat for however many results you want
}
echo "Popular user: ", implode(" &amp; ", $results);

```
```
select user_id, count(user_id) as count from table order by count desc group by user_id

```

something like that anyway...