PHP学习-路由转发
原生php实现页面路由转发,配合占位符实现类似于https://www.mxin.moe/admin@mxin.moe的GET传参方式;
PHP项目结构
demo
| index.php
| .htaccess
└─template
home.php
test.php
Nginx伪静态
PHP项目结构
demo
| index.php
| .htaccess
└─template
home.php
test.php
Nginx伪静态
if (!-e $request_filename){ rewrite ^(.*)$ /index.php; } location ~ /.ht { deny all; }index.php路由
<?php //路由器 $url = $_SERVER['REQUEST_URI']; //获取URL switch ($url) { case '/': include("template/home.php"); break; case '/test': include("template/test.php"); break; }
铭心》原创,转载请保留文章出处。
本文链接:https://www.mxin.moe/post-65.html
版权声明:若无特殊注明,本文为《正文到此结束
管理员已关闭本篇文章评论!