Parliament Hill Computers LtdParliament Hill Computers Ltd

Web log referrals


Why do you need to know who links to you ?

You are getting hits on your web site, but do you know how people find it ? What keywords are being entered into search engines to get to your pages ?

This knowledge is important, especially the search engine keywords - know what people are looking for and you may be able to give them what they want, or you can tune your web site to have the right keywords to find you.

This can be an important part of Search Engine Optimisation ‐ SEO

What other web sites link to you ? Some you may know of, others you might not or have forgotten. How useful or effective are these other sites ?

This is all about generating more web traffic which (hopefully) means generating more business & revenue for you.

The Code

Here is some php that will record who links to you. It ignores links from one part of your web site to another.

You use this by putting the following in your php source:

require_once 'LogReferrer.php';
LogReferrer();

You should put LogReferrer.php in a directory that php will search when doing a require_once.

This will append a line to /var/log/httpd/example/referrer_log. This file has to be writable by the web server. You can change this file location by changing the $LogInfo array in LogReferrer. You must change www.example.com to be your domain name, if you have multiple virtual domains you should put one entry for each domain, the log files may be the same or different.

License and copyright

All description & sample files copyright (c) 2005 Parliament Hill Computers. Author: Alain D D Williams.

You may used these files as the basis your own (or organisation's/company's) project(s) (under whatever licence that you see fit). You may not claim ownership or copyright of any substantially unmodified files. Acknowledgement would be appreciated, but is not necessary.

These demonstrations are made available in the hope that they are useful. There may be errors: there is no warranty at all, use at your own risk.

Return to tutorial home.

If you want any help using the above, or have any comments or suggestions, please contact us.