【问题标题】:User-friendly URLs for user profiles in YaFYaF 中用户配置文件的用户友好 URL
【发布时间】:2022-05-17 17:50:38
【问题描述】:

我正在使用YAF Framework,并希望通过使用用户名使用户的个人资料链接对用户友好,如果用户名是abdelhady,那么我希望网址是:

www.mysite.com/abdelhady

当然会路由回这样的东西:

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

我尝试过类似的方法,但没有成功:

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

只有当我使用这样的匹配 "match" => "/profile/:username", 时它才有效,但这不是我想要的项目。你有什么建议吗?

【问题讨论】:

    标签: php url-routing yaf


    【解决方案1】:

    使用Yaf_Route_Regex,Yaf_Route_Rewrite不能省略“/”

    【讨论】:

    • 感谢您的回答.. 但是如何在不影响可用控制器的情况下使用它(即profile).. 我的意思是您能否举个例子来解决问题中提到的匹配问题?
    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-05
    • 2012-04-25
    • 1970-01-01
    • 2014-06-20
    • 2011-08-24
    • 2011-01-07
    • 2010-11-07
    相关资源
    最近更新 更多