Configure urlManager for wildcard subdomain Yii2

Hello,

I configured my localhost environment with dnsmasq for wildcard subdomain.

Well, if my addresses will be like : http://username.example.com

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

thanks for the answers.

http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#rules-with-server-names

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+>.shop.me/' => 'user/index',

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



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


http://AlaFalaki.shop.me

is equal to


http://shop.me/user/index?id=AlaFalaki

Another example:


http://AlaFalaki.shop.me/about

is equal to


http://shop.me/user/about?id=AlaFalaki

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