Home  >  Article  >  PHP Framework  >  How to solve the TP6 error "The current access route is not defined or does not match"

How to solve the TP6 error "The current access route is not defined or does not match"

藏色散人
藏色散人forward
2020-06-29 17:50:0718258browse

下面由thinkphp框架教程栏目给大家介绍ThinkPHP 6.0 多语言优化扩展包,希望对需要的朋友有所帮助!

How to solve the TP6 error

如果是报路由错误,则说明启用了路由控制,那么所有被访问的页面都需要配置路由,否则将无法访问。
例如:
在浏览器中运行http://hml.tp6.com/admin/getlog
报错:当前访问路由未定义或不匹配
How to solve the TP6 error The current access route is not defined or does not match

已设置过路由:
How to solve the TP6 error The current access route is not defined or does not match

原因:当前访问方式是post,在浏览器中无法模拟访问,必须在apipost中访问。改成get方式也可以。

另注意:如果是多应用模式架构的话,路由要带上模块名,如admin。如图所示目录层级。
How to solve the TP6 error The current access route is not defined or does not match

如图:访问成功
How to solve the TP6 error The current access route is not defined or does not match

如果报404错误,一般是客户端的问题,url输入有误,将你的域名后加上index.php试下,例如你需要访问的路由是:

http://hml.tp6.com/admin/getlog,那么你可以写成这样:http://hml.tp6.com/index.php/admin/getlog
这种情况设置一个伪静态即可,在thinkPHP根目录下的public下添加一个文件nginx.htaccess,添加如下代码:

if (!-e $request_filename) {
   		rewrite  ^(.*)$  /index.php?s=/$1  last;
 }

The above is the detailed content of How to solve the TP6 error "The current access route is not defined or does not match". For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete