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