开发者

How would i create a vanity url in codeigniter

How can i create a vanity url in codeigniter. Im开发者_开发技巧 having real trouble doing this in the framework. And there doesnt seem to be any good answers out there.


It's possible, I'm using this in one of my projects...

Here is a thread on the CodeIgniter forums showing how to do it...

http://codeigniter.com/forums/viewthread/113962/


According to Personalized User Vanity URL's in CodeIgniter, you can accomplish this by modifying your routes file:

$handle = opendir(APPPATH."/modules");
while (false !== ($file = readdir($handle))) {
  if(is_dir(APPPATH."/modules/".$file)){
    $route[$file] = $file;
    $route[$file."/(.*)"] = $file."/$1";
  }
}

/*Your custom routes here*/

/*Wrap up, anything that isnt accounted for pushes to the alias check*/
$route['([a-z\-_\/]+)'] = "aliases/check/$1";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜