Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mvc中的url重定向。我想将localhost/windshield-replacement.html重定向到localhost/greenvalleyaz_Php_Url_Model View Controller_Url Routing_Phalcon Routing - Fatal编程技术网

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

Php mvc中的url重定向。我想将localhost/windshield-replacement.html重定向到localhost/greenvalleyaz,php,url,model-view-controller,url-routing,phalcon-routing,Php,Url,Model View Controller,Url Routing,Phalcon Routing,我的应用程序现在在phalcon php框架中。我想重定向一个在末尾包含.html的url。为了重定向,我将控制器名称写为WindshieldReplacementHtmlController.php,但由于中间的点,我无法重定向。我怎样才能解决这个问题 重定向自: localhost/windshield-replacement.html 到 当我键入localhost/windshield replacement html时,它会重定向到目标,但当我使用localhost/windshie

我的应用程序现在在phalcon php框架中。我想重定向一个在末尾包含.html的url。为了重定向,我将控制器名称写为
WindshieldReplacementHtmlController.php
,但由于中间的点,我无法重定向。我怎样才能解决这个问题

重定向自:

localhost/windshield-replacement.html

当我键入
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();

    }
}
参考:

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();

    }
}