-1

When I use the function {{ path('contact_route') }} and its equivalent in controller the generated URL is correct => http://localhost/myproject/web/app_dev.php/contact.

But if I hardcode the URL (I am forced to do so in some particular cases), I get something unwanted, (a href="/contact") => http://localhost/contact

AFA Med
  • 241
  • 2
  • 11

2 Answers2

1

What you are "probably" asking is how to prepend the correct base URL to your manual built URL, i.e. something like this:

a href="{{ app.request.baseUrl }}/contact"

or if you need the FQDN URL:

a href="{{ app.request.getSchemeAndHttpHost() }}/contact"
Francesco Abeni
  • 4,190
  • 1
  • 19
  • 30
0

What you expect if you set <a href="/contact">..., it's nothing more that relative url which point to the referring page plus '/contact'.

malcolm
  • 5,486
  • 26
  • 45