Symfony 4 – How to make subdomain for route?

in my symfony 4 project there are routes for which I would like a base URL different from the others.

For example, for some URLs, it will follow this plan:

https://myApp.com/[route]

But for other routes, I would like something like:

https://app.myApp.com/[route]

I looked at the doc and I saw that it was necessary to use the “host” in the annotations.

Currently I’m developing locally so my URLs look like

127.0.0.1:8000/[route]

So, for a route, by example, I have

    /**
     * Affiche la page de profil de l'utilisateur.
     *
     * @Route("/profile", name="account_profile", host="app.127.0.0.1")
     *
     * @param Request $request
     * @return Response
     */
    public function profile(Request $request)
    { // ... }

And it doesn’t work, no url found here.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *