E.g. I have two domains:
http://www.computer.com
http://www.computers.com
http://www.computer.com is main website and http://www.computers.com is just dummy that will redirect to main website (http://www.computer.com).
So my goal with pure PHP is to detect that user comes from http://www.computers.com rather than google or other website or directly typing url without using refer since it can be disabled.
Both sites are on same hosting, but I cannot access file system of one site from another. And $_SESSION is or $_COOKIE are domain specific variables too.
Your best bet is to to address your issues on multiple levels. First you should point DNS for http://www.computers.com to point at the IP address for http://www.computer.com. Now both of your requests are being served by the same server or cluster of servers(if behind a load balancer).
Second, if you actually want to rewrite the URL to utilize a single domain (to consolidate your cookies, sessions, etc.), then you could use webserver redirection (i.e. mod_rewrite for Apache) to redirect all the requests to the final domain.
Finally, in that rewrite, you should send 301 codes on rewrite to make sure that spiders and such know that this is a permanent redirection.