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 7 '15 at 13:40
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
  • Hi, I have done exactly what you proposed, the rule looks like follows: <rewrite><rules><rule name="MultipleRedirect" patternSyntax="Wildcard" stopProcessing="true"><match url=".*" /><conditions logicalGrouping="MatchAny"><add input="{HTTP_HOST}" pattern="www.othersite.com" /></conditions><action type="Redirect" url="www.contentsite.com" /> </rule></rules></rewrite> 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 9: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 9: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.