Welcome Guest, Not a member yet? Register   Sign In
CI is adding URL parts to links
#2

This is most likely due to how you're creating the links. They are being created without a '/' at the beginning, so the URL is being added onto the current URL as a relative location. If all of the links started with a '/' they would all start at the site root and you wouldn't experience that.

An even better method, though, is to use the URL helper's `site_url()` method with the page link inside of that, like:

Code:
<a href="<?php echo site_url($page.'/'.$item['link']) ?>" target="_self"><?php echo $item['text'] ?></a>


That way if the settings ever change, or if it has to be moved to a subdomain, or if the config gets accidentally tweaked and you suddenly have 'index.php' in the URL again, your links will still work.
Reply


Messages In This Thread
CI is adding URL parts to links - by milosh - 11-07-2014, 08:02 AM
RE: CI is adding URL parts to links - by kilishan - 11-07-2014, 12:06 PM
RE: CI is adding URL parts to links - by milosh - 11-07-2014, 12:29 PM
RE: CI is adding URL parts to links - by kilishan - 11-09-2014, 08:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB