How to disable redirecting between sites on the same IIS server?

5,097

Solution 1

Your site bindings for www.a.com are most likely general enough that they catche www.a.com too. i.e. it's a binding by IP address, which is the same for both sites.

Matt's suggestion will work, to create a custom handler on www.a.com. You can also leave your www.b.com site up, with the binding for www.b.com, and point all traffic to an error page.

Or, you can update your DNS record for www.b.com to point to another server or location entirely.

Solution 2

On your default site,

create a script that shows the error that you want. I had to do the same thing a while ago, because all .domain.tld sites were really just a virtual directory.

<?php
 $f = $_SERVER['server_name'];
 header("Location: http://offline.domain.tld/?q=".$f);
?>
Share:
5,097

Related videos on Youtube

greenoldman
Author by

greenoldman

Updated on September 18, 2022

Comments

  • greenoldman
    greenoldman over 1 year

    I have one server, and two sitets -- let's say A and B.

    The problem (for me) is when I shut down B site, when I try to browse:

    www.b.com
    

    instead of displaying an error, IIS redirects me (silently) to A, so in effect I get the addres:

    www.a.com
    

    So how to block this redirection (and display an error)?

    IIS 7.

  • greenoldman
    greenoldman over 13 years
    Btw. inn my case each site has its own directory. So I should create additionaly another site (the default one) which purpose is just to show an error, right? If any of the sites, A or B, are down, the redirection will go to the default one. Did I understand you correctly?
  • Scott Forsyth
    Scott Forsyth over 13 years
    Yes, that will work. The trick will be to make it so that you can't forget to turn the fallback site on. You mention that you're using IIS 7. Have you considered URL Rewrite? With URL Rewrite, you could add a rule to the www.a.com site to listen for all traffic where {HTTP_HOST} = www.b.com and throw a custom error page. Then when www.b.com is turned off, the URL Rewrite rule will kick in. That's similar to Matt's suggestion, so it's a matter of which method you prefer of catching and redirecting your site.