CodeIgniter Forums
[CLOSED] Custom Url Library Class Sub Folder Pickup - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: [CLOSED] Custom Url Library Class Sub Folder Pickup (/showthread.php?tid=60822)



[CLOSED] Custom Url Library Class Sub Folder Pickup - El Forum - 07-07-2014

[eluser]riwakawd[/eluser]
I am trying to be able to get my custom url library class to pick up link in any folder but can not get it to work.

It works fine like $this->url->link('user);

But will not pick up controller in sub folder $this->link->url('user/user); it shows link OK but not going to it.

Code:
<?php

class Url {

private $host;
private $rewrite = array();

public function __construct($host = '', $ssl = '') {
  $this->host = $host;
  $this->ssl = $ssl;
}

public function addRewrite($rewrite) {
  $this->rewrite[] = $rewrite;
}

public function link($route, $args = '', $secure = false) {
  if (!$secure) {
   $url = $this->host;
  } else {
   $url = $this->ssl;
  }

  $url .= 'index.php' . $route;
  foreach ($this->rewrite as $rewrite) {
   $url = $rewrite->rewrite($url);
  }

  return $url;
}
}