正确处理Yii2中的基本URL(Proper handling of base url in Yii2)

编程入门 行业动态 更新时间:2024-10-27 19:27:47
正确处理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->baseUrl

accesses 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

本文发布于:2023-07-26 19:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1280246.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确处理   URL   Proper   base   handling

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!