You don't have to do anything special or load any helpers, just keep in mind that paths will be relative to the url and not the filesystem or controller.
Assuming your installation is in the root directory of your domain, let's say your current URL is http://localhost/class/method/var
:
<a href="/main/create">Will work from anywhere</a>
<a href="create">Will go to http://localhost/class/method/var/create</a>
<a href="../create">Will go to http://localhost/class/method/create</a>
Relative paths are not your friend in Codeigniter, you are better off sticking with full urls (typically using the helper functions like base_url()
and site_url()
), or to use the forward slash (relative from root). People have mentioned using the <base>
html tag, but I don't personally recommend it. You are going to have some very wacky urls if you use ../../relative
paths when you get deeper into the url segments. Example:
If you are here:
http://localhost/controller/method/var1/var2/var3
A link might look like this:
<a href="../../../../controller2/method/othervar"></a>
Probably not what you want, but it's an option you may choose. I recommend using one of the other two.