0

we have a web server with several websites. Of these, only one site has real content, the other sites are used to redirect requests to the content site. This is done by the IIS http redirect.

  • www.contentsite.com -> web site with content
  • www.othersite1.com -> redirects to content site (IIS http redirect)
  • www.othersite2.com ...

Is it possible to accomplish this by using the IIS URL rewrite module so that the redirect sites can be omitted?

  • You can achieve the same with no redirects using IIS Bindings. Expanding IIS to the site with content > right click then Edit Bindings and just type in the domain name of each site. – EvilDr Jan 07 '15 at 13:40

1 Answers1

1

Yes, add an inbound rule. Set it to be:

  • Match URL: .* to match any request path
  • Conditions: {HTTP_HOST} Matches the pattern www2.example.org - use this section to match your other hostnames, e.g. add another {HTTP_HOST} for www3.example.org, and set the condition logical grouping to Match Any
  • Action: Redirect
  • Action Properties: http://www.example.org
TessellatingHeckler
  • 5,726
  • 3
  • 26
  • 44
  • Hi, I have done exactly what you proposed, the rule looks like follows: I have stopped the redirect page (othersite.com), but now, if I insert the url, I get to the default IIS page. I have restarted the app pool and site without success. Am I missing something else? – AGuyCalledGerald Oct 24 '14 at 09:37
  • 1
    Where have you put the rewrite rule? Is it within one of the sites, or at the top/server level? It sounds like IIS is answering the connection, seeing a request for 'www.othersite.com', and not knowing what to do with it. e.g. if you put the rewrite rule in the URL Rewriter inside the main content site, then you need to edit the content site bindings, and add 'www.othersite.com' as an extra hostname that it handles. Then IIS can send the request to the content site, and the redirect can handle it. – TessellatingHeckler Oct 24 '14 at 17:34
  • Thanks again! I had put the rewrite rule into the content site. Now I have added a binding "www.othersite.com" in the content site and removed it from the other site. The redirect is working fine, but now I see "www.othersite.com" in the address bar. Is it possible to change that? – AGuyCalledGerald Oct 27 '14 at 09:58
  • I'm not sure; that is what I would expect if the redirect was not working - the content site answers to the othersite name and serves the content, and the browser shows the wrong name. If the redirect works, the browser connects once, gets the redirect, and starts again with the new address and the address bar changes to show that. Can you use the dev tools in the browser (commonly F12 key) and watch the Network/Net tab while the page loads, make sure the 301 or 302 redirect is actually getting to the browser? – TessellatingHeckler Oct 27 '14 at 12:37
  • Yes, it is not working. There is no redirect coming from the content site. I think it should initiate a redirect to itself, but it is never happening... – AGuyCalledGerald Oct 27 '14 at 13:22