2

我的应用程序现在位于 phalcon php 框架中。我想重定向一个最后包含 .html 的 url。为了重定向,我将控制器名称写为WindshieldReplacementHtmlController.php但由于中间的点我无法重定向。我该如何解决这个问题?

重定向自:

localhost/windshield-replacement.html

localhost/greenvalleyaz

当我键入localhost/windshield-replacement-html它重定向到目标但当我使用localhost/windshield-replacement.html它时没有检测到控制器。这是正确的方法吗?

4

1 回答 1

2

在 MVC 中,您不应该直接显示视图

您必须访问控制器操作->在操作中您必须呈现视图

在我要展示的示例中,我user/order.phtml 将从浏览器访问此页面 localhost/appname/user/orders

用户控制器.php

use Phalcon\Mvc\View;

class UserController {

    function ProfileAction(){  //access localhost/appname/controller/profile
    }

    function loginAction(){ //access localhost/appname/controller/profile
    }

    function ordersAction(){ //access localhost/appname/controller/orders

         $view = new View();

         // Setting views directory
         $view->setViewsDir('app/views/');

         $view->start();

         // Shows recent posts view (app/views/user/orders.phtml)
         $view->render('user', 'orders');
         $view->finish();

         // Printing views output
         echo $view->getContent();

    }
}

参考:Phalcon_Mvc_View

于 2016-12-20T07:43:07.933 回答