Whenever I am hitting the URL https://localhost:9002/trainingstorefront/?site=electronics, it always redirects to the site homepage. How this request mapping actually happens and where does it decide that which is the site to be loaded.
For this, you must be aware of the filter chain that is used before any url is actually handled by a controller. This filter chain list can be easily found in the storefront web folder.
The Url is mapped using the CMSSiteFilter present in your storefront extension.
For the whole list of such filter, check spring-filter-config.xml in your storefront extension.