Subdomains control for url in slim

Hi there,

I would like to create multiple sudbomain eg:

these subdomains will be dynamic and I would like to have different controllers based on the subdomain and load from a single twig file

I am still new to the slim framework so apollogies for the noob question

There is not any built-in support for parsing subdomains. However, here’s how I would do this. I would configure the default Nginx virtual host to answer for these subdomains. The virtual host will direct all PHP requests to the appropriate Slim bootstrap file. You can write a simple Slim middleware that parses the request subdomain so you can take the necessary actions in your route callbacks. Does this make sense?

1 Like

Maybe switching to for routing could help too? It’s inspired by fastroute, so could be close enough and slim4 decoupled the router completely afaik. Anyone tried this?