Search code examples
phphyperlinkpathyii2href

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


I use Yii2 framework and I want to have a link in a php file called index.php to a pdf file called abc.pdf but the path that I wrote is not working:

I have these files:

  • my-project/backend/views/my-form/index.php

  • my-project/backend/views/my-form/abc.pdf

This is code of the element that is not working of index.php:

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

Which is the path that should work? I tried relative and absolut paths but I think I am writing it wrong.


Solution

  • I resolve it doing the folowing.

    I placed the abc.pdf file in the /backend/web folder.

    Then I referenced it at index.php using:

    <a href="abc.pdf">