正确处理Yii2中的基本URL(Proper handling of base url in Yii2)
在Yii2基本和高级模板中,
Yii::$app->request->baseUrl访问应用程序的基本URL。
但是如何在Yii2中设置基本URL?
In Yii2 basic and advanced templates,
Yii::$app->request->baseUrlaccesses the base url of the app.
But how does one set the base url in Yii2?
最满意答案
如果你想强制执行它,你可以设置它:
\Yii::$app->request->baseUrl = 'http://whatever.com';它将覆盖从实际请求( Request::getScriptUrl() )获得的任何内容,直到再次将其设置为null 。
If you want to enforce it you can just set it:
\Yii::$app->request->baseUrl = 'http://whatever.com';It will override whatever was obtained from the actual request (Request::getScriptUrl()) until you set it to null again.
更多推荐
Yii,$app->request->baseUrl,基本,URL,电脑培训,计算机培训,IT培训"/> <meta
发布评论