User-friendly URLs for user profiles in YaF

限于喜欢 提交于 2019-12-13 02:45:33

问题


I'm using YAF Framework and want to make the user's profile link to be user-friendly by using their usernames, if username is abdelhady so I want the url to be:

www.mysite.com/abdelhady

which of course will route back to something like this:

www.mysite.com/profile/get/username/abdelhady

I've tried something like this, but it didn't work:

    $config = array(
        "community" => array(
            "type" => "rewrite",
            "match" => "/:username",
            "route" => array(
                'controller' => "profile",
                'action' => "get",
            )
        )
    );
    Yaf_Dispatcher::getInstance()->getRouter()->addConfig(
            new Yaf_Config_Simple($config));

It only works if I used a match like this "match" => "/profile/:username", , but it is not what I want for my project. Do you have any suggestions?

来源:https://stackoverflow.com/questions/18875717/user-friendly-urls-for-user-profiles-in-yaf

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