cancel
Showing results for 
Search instead for 
Did you mean: 

Swtiching Sites with same domain

Former Member
0 Kudos
1,428

HI Guys

I have a requirement where I need to have sites specific to two countries. (eg. foo and goo) but my domain remains the same. ( www.mycompany.com ). So I need two sites with something like this


  1. www.mycompany.com/foo

  2. www.mycompany.com/goo


Both these countries have their specific catalogs, base store, sites.

Just needed to understand what is the best way to handle site switching in this situation.

Thanks Bhanu P Jain

View Entire Topic
Former Member
0 Kudos

I have done the following uptill now:

CMS Site URLs

  1. site foo: (?i)^https?://mycompany.[^/]+/store+(/[a-z][a-z])+foo+(|/.|\?.)$

  2. site goo: (?i)^https?://mycompany.[^/]+/store+(/[a-z][a-z])+goo+(|/.|\?.)$

Actual SITE URLs

  1. site foo: https://mycompany.com:9002/store/en?clear=true&country=foo

  2. site goo:https://mycompany.com:9002/store/en?clear=true&country=goo

I have modified the 'processNormalRequest' method of CMSSiteFilter as below:

if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM))

{

final String country = httpRequest.getParameter(PARAM_COUNTRY);

if(StringUtils.isEmpty(country)){

/No Country Fetched from the URI/

httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_COUNTRY_ERROR_MESSAGE);

return false;

}

final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + "/" + country

+ (StringUtils.isBlank(queryString) ? "" : "?" + queryString);

cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL);

}

Now sending the country in query params, adding this to the absolute URL while fetching site for the requestURI works great.

The problem is now handling both the sites in the same browser . For eg: if I open foo site in tab1 and log in. Now in tab2 I open goo site, the site of tab1 changes to goo but the user is still logged in.

How to handle this situation. What if I want both the sites to maintain their own session in the same browser?

sandeep_n_reddy
Explorer
0 Kudos

Hi Bhanu

I am also having the same issue, did you find the solution to open two diff sites with same domain in two tabs of same browser??

Response is appreciated.

Regards Sandeep