- index.php
- cms-page.php
如果请求ULR是
www.example.com/service或
>www.example.com/about us
则cms page.php应打开
我该怎么走。写什么,在哪里写才能得到这样的结果。谢谢
在core php中,您可以做这样的事情来实现。
//get request url
$url = rawurldecode($_SERVER['REQUEST_URI']);
//match the request url with above urls.
if(preg_match('/service/', $url) || preg_match('/about-us/', $url)){
//open cms page.
include('cms-page.php');
}
在一般实践中,将你的url解码和重定向部分保存在一个单独的php文件中,然后将它们重定向到路由器,路由器应该采取适当的行动。请参阅以下结构。
URL DECODER -> ROUTER (takes to controller) -> CONTROLLER (determines view ) -> VIEW