Home  >  Article  >  Backend Development  >  How to solve too many redirects in php

How to solve too many redirects in php

(*-*)浩
(*-*)浩Original
2019-09-30 10:45:258097browse

Due to project needs, the project that used Apache as the server in the past needs to be changed to Nginx, but after the change, a problem occurred. When accessing directly using the domain name, it prompts "The webpage cannot operate properly. There have been too many redirects ERR_TOO_MANY_REDIRECTS" ".

How to solve too many redirects in php

Through step-by-step breakpoint output of the code, we found that the reason is that the default access module (default controller and default method) or the default access module (default controller and default method) has not been set. Default controller and default method) do not exist. So this is the reason.

The solution is as follows: (Recommended learning: PHP video tutorial)

The homepage directly configures the jump to admin.php, but due to \thinkphp In the \library\think\Request.php file, the pathinfo() function returns $this->pathinfo;

The result is '/', in this case, the default setting will be found in the configuration file. Controllers and operations, because this default access module, controller, and method are not performed, the "Too many redirections" error is returned.

We only need to change the default_module (default module name) configuration, default_controller (default controller name) configuration and default_action (default operation method name) configuration in the \application\config.php configuration file in tp5 to existing ones Just controllers and methods:

    // 默认模块名
    'default_module'         => 'home',
 
    // 默认控制器名
    'default_controller'     => 'Index',
 
    // 默认操作名
    'default_action'         => 'index',

The above is the detailed content of How to solve too many redirects in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn