CodeIgniter Forums
url_helper useless to me? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: url_helper useless to me? (/showthread.php?tid=52254)



url_helper useless to me? - El Forum - 06-03-2012

[eluser]georgeoneill[/eluser]
Hi

I'm brand new to CI and having fun figuring it out. There's one major thing bothering me, I must be doing something wrong.

When I try to use the url helper functions (anchor() and redirect() to be specific), I get funny results. It seems to me that this is because they use site_url() instead of base_url().

I've used .htaccess to remove index.php from my urls, and I have the corresponding $config variable set to an empty string, as instructed.

Here's my example: if i'm on the page localhost/example/default and I have the code
Code:
anchor('somepage', 'link')

I'm expecting to get sent to: localhost/example/somepage when I click the link.

but instead i'm taken to: localhost/example/default/localhost/example/somepage

I can easily work around this with native php, but I feel like I want to use the full capabilities of CodeIgniter whenever possible. Also I'm tempted to rewrite the functions using base_url instead of site_url but that seems too ham-handed.


url_helper useless to me? - El Forum - 06-03-2012

[eluser]Cristian Gilè[/eluser]
What is the site URL, as specified in your config file?


url_helper useless to me? - El Forum - 06-03-2012

[eluser]Abel A.[/eluser]
You probably didn't set your configs properly.


url_helper useless to me? - El Forum - 06-03-2012

[eluser]georgeoneill[/eluser]
$config['base_url']= "127.0.0.1/dmc_CI";

$config['uri_protocol'] = "AUTO"; I played with this one a bit, but with no luck.


url_helper useless to me? - El Forum - 06-03-2012

[eluser]CroNiX[/eluser]
Read the notes in the config file right where you changed that. Notice anything missing from your base_url that they mention needs to be there? Smile


url_helper useless to me? - El Forum - 06-03-2012

[eluser]georgeoneill[/eluser]
Oh, snap!


url_helper useless to me? - El Forum - 06-03-2012

[eluser]Learn CodeIgniter[/eluser]
Code:
anchor('controller/function', 'link')