User-friendly URLs for user profiles in YaF

2019-07-27 10:18发布

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?

0条回答
登录 后发表回答