url 在 mvc 中重定向。我想将 localhost/windshield-replacement.html 重定向到 localhost/greenvalleyaz

url redirect in mvc . i want to redirect localhost/windshield-replacement.html to localhost/greenvalleyaz

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

重定向自:

localhost/windshield-replacement.html

localhost/greenvalleyaz

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

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

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

在我要展示的例子中user/order.phtml 我将从浏览器 localhost/appname/user/orders

访问此页面

UserController.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