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

101 views Asked by At

My applications is now in phalcon php framework. I want to redirect a url which contain .html at the end. To redirect, I wrote the controller name as WindshieldReplacementHtmlController.php but because of the dot in between I could not redirect. How can I solve this?

Redirect from:

localhost/windshield-replacement.html

to

localhost/greenvalleyaz

When I type localhost/windshield-replacement-html its redirecting to the target but when i use localhost/windshield-replacement.html its not detecting the controller. is it the correct way to do that ?

1

There are 1 answers

0
Mohammad Fareed On BEST ANSWER

In MVC you should not show the View Directly

you have to access a controller action --> in action you have to render view

In the Example I want to show user/order.phtml I will access this page from Browser 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();

    }
}

Refer : Phalcon_Mvc_View