Yii2 和 href:如何使用指定 link 的目的地?

Yii2 and href: How to specifies the link's destination using?

我使用 Yii2 框架,我想在一个名为 index.php 的 php 文件中有一个 link 到一个名为 abc.pdf 但我写的路径不起作用:

我有这些文件:

这是 index.php 不工作的元素代码:

<a href="abc.pdf">Link to abc</a>

哪条路径应该有效?我尝试了相对和绝对路径,但我认为我写错了。

尝试使用 html helpers 构建正确的路径

    use  yii\helpers\Html;

    <?= Html::a('Link to abc', ['my-form/abc.pdf']) ?>

点击这里了解更多http://www.yiiframework.com/doc-2.0/guide-helper-html.html#hyperlinks

我通过以下方式解决了它。

我将 abc.pdf 文件放在 /backend/web 文件夹中。

然后我在 index.php 引用它使用:

<a href="abc.pdf">

如果你只是想在 href 属性中传递它;使用

<a href="<?= \yii\helpers\Url::to(['/site/registeruser']) ?>" class="btn btn-success">Profile</a>