> ## Content Index
> Fetch the complete content index at: https://mfitzp.ghost.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# Find Top 404 Error Pages with Apache
- URL: https://mfitzp.ghost.io/find-top-404-error-pages-apache/
- Published: 2011-11-07T00:00:00.000Z
- Updated: 2023-06-25T18:09:02.000Z
- Author: Martin Fitzpatrick
- Tags: Tutorials, #Import 2024-03-14 08:20, #Import 2026-08-24 14:26

A quick one-liner to find the most common pages giving 404 errors on your apache2 setup. Set this up as a shell alias to get easy access at any time.

```bash
cut -d'"' -f2,3 /var/log/apache/access.log | awk '$4=404{print $4" "$2}' | sort | uniq -c | sort -rg

```

Replace *`/var/log/apache/access.log` with the path to your own Apache setup. On web hosts this may be under `~/logs/apache` or elsewhere.*

*This one liner breaks down as follows:*

1. *`cut` splits the input (the logfile) by `-d` delimiter and returning only the fields given by \`-f\`\`*
2. *Output is piped into `awk` which searches for lines where field 4 = 404, returning these as a line containing `404 URL`*
3. *These are then sorted (so duplicates can be counted) with `sort`*
4. *`uniq -c` counts the duplicates chucks them away and appends a number to the beginning of each row that is left*
5. *The resulting output is then `sort`ed numerically `-g` and `-r` reverse (highest first - remove this to get the top ones at the bottom of the list)*