What you're looking for is $_SERVER['HTTP_REFERER']. This will tell you where the user has come from, however, it is based on clicked links, and if I'm not mistaken, script redirects, as opposed to a 301 redirect at the server level (Apache). I'm not sure how else you would be able to track this.
Hi
Having moved my site from a subdomain of gospelcom (ied.gospelcom) to its own domain http://www.internetevangelismday.com there are permanent 301 redirects from ied.gospelcom.net to the new domain, for each page.
If I use PHP to find the referrer to any age, it displays the correct original linking page, irrespective of whether it was linking to ied.gospelcom.net or the new domain.
Is there any sort of page property that PHP can detect, that would show the page had been a redirect from the subdomain, rather than a direct link?
blessings and thanks
Tony
Online outreach:
Internet Evangelism Day
Helping church websites:
Church Websites