CodeIgniter Forums
Here we go again, Anchor function doubles up url on call - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Here we go again, Anchor function doubles up url on call (/thread-43851.html)



Here we go again, Anchor function doubles up url on call - El Forum - 07-25-2011

[eluser]edziffel[/eluser]
Finally got my anchor tag to call a method/function in the controller.
?php echo anchor('/drawback/hoeboy', 'click here');?>

Unfortunately on click it generates the following URL:

http://localhost/drawback.com/localhost/drawback/index.php/drawback/hoeboy

which ain't working, don't care where yer from. Note the right url which works fine

localhost/drawback/index.php/drawback/hoeboy, is appended to the current root url http://localhost/drawback.com.

Checked Url and anchor in users guide. Didn't see a cure.

A config setting? Played with a few the Url, routes etc. Didn't work.

Code:
function hoeboy() {
                echo "oh not again";
                }

It's not the code for hoeboy but included it so that it was clear that isn't it.

Ideas?

Thanks


Here we go again, Anchor function doubles up url on call - El Forum - 07-25-2011

[eluser]edziffel[/eluser]
Little more info; just changed the anchor call to an <a> call with the correct url

Code:
<a href="http://localhost/drawback.com/index.php/drawback/hoeboy">Upload Data here</a>

Works fine like that and allows me to continue, but really want to get it working with just CI. Don't like slop.


Here we go again, Anchor function doubles up url on call - El Forum - 07-25-2011

[eluser]InsiteFX[/eluser]
I told you before and I will tell you again remove the first /

InsiteFX


Here we go again, Anchor function doubles up url on call - El Forum - 07-25-2011

[eluser]edziffel[/eluser]
InsiteFX

Thanks for the reply. Was pretty sure I did a bunch of "guess-a-fix" stuff to include playing with the quotes, none, double, single, and adding and removing slashes. Removed the leading front slash again tested and put it back, tested, and removed it again and tested, just to make sure and same results. Does the idea that removing the front slash doesn't change the results mean anything?

Browser set up properly to test: reloads every time. Uncommented out the anchor function and it fired right up then disappeared when commented out again just like it's supposed too. On fresh Linux install, fresh CI install. All else working as expected. Just FYI.


Here we go again, Anchor function doubles up url on call - El Forum - 07-26-2011

[eluser]InsiteFX[/eluser]
Check your config base_url and make sure it has / on the end of it.


Here we go again, Anchor function doubles up url on call - El Forum - 07-26-2011

[eluser]edziffel[/eluser]
InsiteFX

You nailed it! My default base_url in the config.php file was wrong, by a bunch. In retrospect, its surprising that it worked at all. Probably would not have figured it out in a month if you hadn't pointed me to it. Will double check all config entries to ensure that they comply to the example model.

You rock dude and thanks again!

Ed