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('controller/method')
:
<a href="http://localhost/dts/controller/method">Link</a>
<a>
:
<a href="controller/method">Link</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/method2
, then if the form is submitted again, redirects to controller/controller/controller/method2
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.
index_page is set to:
$config['index_page'] = "";
base_url is set to:
$config['base_url'] = "http://localhost/program/";
.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
that's based on this because the .htaccess provided by the CI manual doesn't work.
Any ideas?