Thursday, April 12, 2012

URL relativity and codeigniter

I set the url:


$this->session->set_userdata('destination', $this->input->server('REQUEST_URI'));
 


Then redirect (doesn't work because it prepends site address):


redirect($this->session->userdata('destination'));
 


Is it possible to redirect to an absolute address and would this be a better option considering REQUEST_URI will always be correct on different domains?



Answer:

You need to have an absolute address for the redirect, like:
/account/user/1/jason
or
http://domain.com/accounts
A relative link makes no sense here:
somewhere/link as it does not specify where this 'location' is to the browser.
Keep in mind the redirect() is a HEADER REDIRECT (by default) Read about it here:http://codeigniter.com/user_guide/helpers/url_helper.html

No comments:

Post a Comment