Keeping original HTTP_HOST when Redirecting/Rewriting

529 views Asked by At

I am experiencing an issue with the IIS Rewrite Module and nopCommerce.

Situation:

I have several domains (Domain1.ca, Domain2.ca, etc.), each redirecting to a main domain (MainDomain.ca) at the Registrar level (using a CNAME record). Is it possible, using the IIS 8 Rewrite module, to retain the original HTTP_HOST value of the domain originally browsed to (Domain1.ca, Domain2.ca, etc.) instead of the redirected domain (MainDomain.ca)? I need this for the following reason:

In nopCommerce, each store corresponds to a unique domain (Store1 = Domain1.ca). To determine which store is active, nopCommerce obtains and resolves the "HTTP_HOST" value.

Unfortunately, since all domains get redirected to the main domain (MainDomain.ca), the original HTTP_HOST value (Domain1.ca) is lost. Therefore, not knowing which specific store needs to get activated, nopCommerce activates the first one in the list.

I assume that when a site has been redirected to, the original HTTP_HOST value is overwritten.

Does anyone have any experience with nopCommerce, HTTP_HOST, multi-store, domain redirection?

1

There are 1 answers

2
snake On

a CNAME does not perform any redirection. A CNAME simply says that domain1.com will us ethe same dns records as domain2.com, aka it is an alias.

So if you are really are redirecting from your domain registrar then you are not using a CNAME record to do this. You must be using a REDIRECT service at the registrar, the most common one is an FRAME redirect, where they create a website for domain1.com and inside they put a frameset which points to domain2.com

I would suggest that remove this, and just use the CNAME only and then do the redirect at your webserver using URL REWRITE, this will then allow you to retain the original host name.