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?

1
  • 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, 2015 at 13:40

1 Answer 1

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
5
  • 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? Oct 24, 2014 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. Oct 24, 2014 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? Oct 27, 2014 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? Oct 27, 2014 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... Oct 27, 2014 at 13:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .