Issue with URL's

#1
[eluser]evolve08[/eluser]
Hello all, new user of CI, but long time PHP programmer and web developer.

I'll jump right into it. I seem to be having some issues with links. The default action is index, however if the URL isn't set to <controller>/index URL's become messed up and I'm not really sure why (they point to the default route).

So, <controller>/ and <controller>/index are not acting the same way, and I think they should be.

I know I can avoid the problem by using the anchor helper, however I'm converting a pre-existing script with a lot of links and would rather not change them all within the view.

Hope I am explaining this correctly.

#2
[eluser]evolve08[/eluser]
Let me try to explain this a little clearer.

Say I have a URL
http://127.0.0.1/fence/components

Everything works fine with links like:
Code:
<a href="./components/view/&lt;?=$row->id?&gt;">view</a>

However say I have the URL:
http://127.0.0.1/fence/components/index

Then the links which worked fine before point to something similar to...
http://127.0.0.1/fence/components/components/edit/12

Which is correct technically, but I need a way to prevent or stop this, I'm hoping its simply a configuration option somewhere.

Thanks in advance.

#3
[eluser]Rick Jolly[/eluser]
Three options:
Code:
// 1. using the "base" tag in the "head" you can use relative urls:
&lt;base href="&lt;?=base_url();?&gt;"&gt;&lt;/base&gt;
<a href="components/view/&lt;?=$row->id?&gt;">view</a>

// 2. absolute
<a href="&lt;?=base_url();?&gt;components/view/&lt;?=$row->id?&gt;">view</a>

// 3. relative to webroot
<a href="/components/view/&lt;?=$row->id?&gt;">view</a>


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.