Configure urlManager for wildcard subdomain Yii2


I configured my localhost environment with dnsmasq for wildcard subdomain.

Well, if my addresses will be like :

What can i put in urlManager rules to pass the username part of the url to my controller ?

thanks for the answers.

Did you get it to work with the username as a dynamic subdomain?

Would love to see what you have done to get it working


Well, actually i finally find out how to do it,

First you should active Wildcard subdomain configuration on your server, you can google it.

After activating, you can use URL rules like this:

'http://<id:\w+>' => 'user/index',

'http://<id:\w+><action>' => 'user/<action>',

Whit this rule, any request that goes to e.g.

is equal to

Another example:

is equal to

This is what i did, i hope this will help you.