Reputation: 11
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.
Upvotes: 1
Views: 1062
Reputation: 11
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.
Upvotes: 0
Reputation: 5810
Site mapping is done through regex (urlPatterns) which you can find under your CMSSite.
$siteUid=electronics
# CMS Site
INSERT_UPDATE CMSSite ; uid[unique=true] ; urlPatterns ;
; $siteUid ; (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$,(?i)^https?://$siteUid\.[^/]+(|/.*|\?.*)$;
As you see here, (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$
regex is associated with electronics CMSSite. Which mean if you hit https://localhost:9002/trainingstorefront/?site=electronics URL it land with electronics site.
You can change this urlPatterns regex as per your requirement.
e.g. I want the user to land on the electronics site when they hit https://localhost:9002/trainingstorefront/ (without ?site=electronics), to achieve this I'll add (?i)^https?://[^/].*$
to urlPatterns
$siteUid=electronics
# CMS Site
INSERT_UPDATE CMSSite ; uid[unique=true] ; urlPatterns ;
; $siteUid ; (?i)^https?://[^/]+(/[^?]*)?\?(.*\&)?(site=$siteUid)(|\&.*)$,(?i)^https?://$siteUid\.[^/]+(|/.*|\?.*)$,(?i)^https?://[^/].*$ ;
Upvotes: 2