Codeigniter redirect with base_url
- by Obay
I noticed that anchor('controller/method') produces a different result than a mere <a href="controller/method"> in that anchor() adds the base_url:
anchor():
<a href="http://localhost/dts/controller/method">View Timesheet</a>
<a>:
<a href="controller/method">View Timesheet</a>
How do I achieve this same effect (anchor) in my controller? That is, adding the base_url in my redirects?
I'm asking because I have a form that calls another method method2, which has a redirect('controller/method'). But it redirects incorrectly to controller/controller/method, then if the form is submitted again, redirects to controller/controller/controller/method and so on.
That's why I'd like to know how to redirect to controller/method with the base_url pre-prended to it. redirect( base_url() . 'controller/method' ) doesn't work.
Any ideas?