- Introduction to Logging in Apache
- Default Apache Log Files
- Creating Log Formats
- Creating a Custom Log File
- Redirecting Logs to an External Program
- Logging Requests Conditionally
- Monitoring Who Is Linking to Your Website
- Monitoring Apache with mod_status
- Monitoring Apache with SNMP
- Analyzing Your Logs with Open-source Tools
- Monitoring Your Logs in Real Time
- Logging Requests to a Database
- Rotating and Archiving Logs
- Controlling IP Address Resolution
- Processing Logged IP Addresses
- Restarting Apache Automatically If It Fails
- Merging and Splitting Log Files
- Keeping Separate Logs for Each Virtual Host
- Common Log Entries
Monitoring Who Is Linking to Your Website
SetEnvIfNoCase Referer www\.example\.com internalre- ferral LogFormat "%{Referer}i -> %U" referer CustomLog logs/referer.log referer env=!internalre- ferral
In order to monitor who is linking to your website, you can log the Referer: header from the request. This header contains the URL that linked to the page being requested. While not always present or accurate, it works for the majority of cases. This example shows how to use an environment variable to log the referrer information to a separate file. In this particular case, we are only interested in logging external referers, not those that come from an internal web page. To do so, in this example we check whether the referrer matches our own domain.