How would i create a vanity url in codeigniter

和自甴很熟 提交于 2020-01-12 10:30:47

问题


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.


回答1:


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/




回答2:


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";


来源:https://stackoverflow.com/questions/2761259/how-would-i-create-a-vanity-url-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!