Welcome Guest, Not a member yet? Register   Sign In
url duplication
#1

[eluser]Unknown[/eluser]
I have searched the forum and have not come across this. First, let me say I am new to CI, so bear with my newbie questions. I am roughing out the site navigation for my new site and have a menu of links

Code:
<ul>
  <li><a href="home/profile">User Profile</a></li>
  <li><a href="home/help">Help Page</a></li>
  <li>etc...</li>
<ul>

This view is created in my Home index() function and operates fine.

However, once I have moved back and forth a few times, my url's start to take me to

Code:
http://mysite.com/index.php/home/profile/home/profile   <-- Note the duplication

instead of the normal

Code:
http://mysite.com/index.php/home/profile

They look fine when using "view source", but you can see the different URL that is created in the status bar when you hover over the link, and it takes me to a 404 page (of course).

I can't tell what is different.

Some clarifying info. Upon successful login, I do
Code:
header('Location http://mysite.com/home/index.php');
This seems to work fine.

if the login fails, I link to "home/login_failed" where it is

Code:
login_failed()
{
  $this->error_message = "Login Failed";
  index();
}

Any ideas why going to the exact same page via a direct link differs from going to the same page via a redirect or via a subroutine call? (I think the problem is with the subroutine version).

Greg
#2

[eluser]pistolPete[/eluser]
You should use absolute urls, have a look at the extra / at the beginning of the url:

Code:
<ul>
  <li><a href="/home/profile">User Profile</a></li>
  <li><a href="/home/help">Help Page</a></li>
  <li>etc...</li>
<ul>

Alternatively you could use the url helper: user_guide/helpers/url_helper.html
#3

[eluser]kulldox[/eluser]
see this http://ellislab.com/forums/viewthread/125735/ thread how I solved it.
#4

[eluser]n0xie[/eluser]
You can use the url helper which gives you access to deze 2 functions:
Code:
base_url()
site_url()

These should solve all your problems.
#5

[eluser]Aken[/eluser]
pistolPete's solution is 100% correct, no need to elaborate.




Theme © iAndrew 2016 - Forum software by © MyBB