In Yii 2’s RESTful service, get url/, response 404 solution (response 200)
1. In APM monitoring, due to Alibaba Cloud’s get URL/request, a large number of 404 responses are caused, which has a certain interference to the operation and maintenance work, as shown in Figure 1
2. Request in Postman:http://api.kaiqiu_shujujiexi_api.dev/, response 404, as shown in Figure 2
3. When the request is resolved to an empty route, the so-called default route will be used. why no route tosite/index, the reason is that strict request resolution is enabled in the configuration file, as shown in Figure 3
EnableStrictParsing=> true,
If strict parsing is enabled, the URL of the incoming request must match at least one rule to be considered a valid request, otherwise a yii\web\NotFoundHttpException will be thrown. If strict parsing is disabled, the path information portion of the URL will be considered the route of the request when no rules match the requested URL.
4. Add one to the URL rule, as shown in Figure 4
5. Request in Postman:http://api.kaiqiu_shujujiexi_api.dev/, response 200, as shown in Figure 5
6,site/indexcode in Figure 6





