This should help : http://www.codeigniter.com/user_guide/libraries/user_agent.html $this->load->library('user_agent'); if ($this->agent->is_referral()){ echo $this->agent->referrer(); } or straight PHP: redirect($_SERVER['HTTP_REFERER']);