When the URL is /case or /case/, the image address generated by yii getias is different, which in turn leads to 404
1. The code in the view is implemented as follows  ?>)
when the url ishttp://official.local/casetime, generated
, the image address ishttp://official.local/static/images/header/top.png,响应200
when the url ishttp://official.local/case/time, generated
, the image address ishttp://official.local/case/images/top.png, response 404. How to solve it? as shown in Figure 1
2. Viewhttp://official.local/case/page source code, generated
, the image address ishttp://official.local/case/images/top.png, response 404. as shown in Figure 2
3. Check the debug, the original error has been reported, and the response 404 yii\base\invalidRouteException: Unable to resolve the request “case/”. , as shown in Figure 3
yii\base\InvalidRouteException: Unable to resolve the request "case/". in C:\wwwroot\official-website-management-system\src\vendor\yiisoft\yii2\base\Module.php:561
Stack trace:
#0 C:\wwwroot\official-website-management-system\src\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('case/', Array)
#1 C:\wwwroot\official-website-management-system\src\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 C:\wwwroot\official-website-management-system\src\frontend\web\index.php(18): yii\base\Application->run()
#3 {main}
Next yii\web\NotFoundHttpException: Page not found. in C:\wwwroot\official-website-management-system\src\vendor\yiisoft\yii2\web\Application.php:115
Stack trace:
#0 C:\wwwroot\official-website-management-system\src\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\wwwroot\official-website-management-system\src\frontend\web\index.php(18): yii\base\Application->run()
#2 {main}
4. A small helper method is finally implemented
public static function url($path): string
{
$cdn = Yii::$app->params['cdnDomainHttps'] ?? '';
return rtrim($cdn, '/') . '/' . ltrim($path, '/');
}


