redirect using IIS

Discussion in 'Site & Server Administration' started by Dji-man, May 9, 2005.

  1. #1
    Hi guys,

    I launched many new pages last Friday and deleted old ones. I asked our "network admin" to set-up 301 redirections on our IIS 5 server so that the old pages would redirect to the splash page.

    What I asked was to redirect all files from certain directories to the main page. Eg. warmuseum.ca/cwm/new/index_e.html to warmuseum.ca . What I got redirects the directory, but keeps the files name eg. warmuseum.ca/index_e.html , which is a 404, defeating the purpose of having a redirection in the first place.

    And, since we have different domains pointing to the same content (I know, I know, it's bad.), it only works with the warmuseum.ca domain, and not the other ones.

    So now, I have to explain to him how to do it, even if I am not familiar with IIS.

    Can anyone help me with this? What is the procedure to create a simple redirection on IIS ?

    What was done is :
    - From the "home directory" tab in "Default web site properties",
    - When connecting to this resource, then content should come from : "A redirection to a URL"
    - Redirect to http://www.warmuseum.ca, the client will be sent to: "A permanent redirection for this resource."

    Thanks
     
    Dji-man, May 9, 2005 IP
  2. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #2
    If its .NET you can do
    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","http://www.delphi-central.com/tutorials/");
    }
    </script>
    
    Code (markup):
    Simply save to a file with an ASPX extension.
     
    dct, May 9, 2005 IP
  3. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That's how plain directory redirection works (on any server type) - the same resource (i.e. page) will be requested from a new location.

    The procedure is as you described - in the properties you just type the new path (obviously, not including the file name) and IIS will replace the matching portion of the original path (in your case it's just '/') and will append the rest to the new URL.

    J.D.
     
    J.D., May 9, 2005 IP
  4. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In IIS, the administrator needs to right click on the domain and choose properties. Under the "Home Directory" tab, there are three radio buttons. He needs to choose "A Redirection to a URL" and enter the new location in the text field below. This will set up the 301 redirect to the new location. That's about all you can do in IIS. It's not very robust in this regard.

    Good luck
     
    mopacfan, May 9, 2005 IP
  5. Dji-man

    Dji-man Peon

    Messages:
    185
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks Mopacpan and JD,

    Would it work to redirect all files in the old folders to the splash page?
     
    Dji-man, May 9, 2005 IP
  6. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes, it will send any request for any page from the old host to the new location.
     
    mopacfan, May 9, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I only have IIS6 around - you will have to look for equivalent functionality in IIS5. Here's what you need to do:

    * In the website properties select Home Directory > A redirection to a URL;

    * Check the checkbox The exact URL entered above;

    That's it. All requests will end up requesting this new URL.

    J.D.
     
    J.D., May 9, 2005 IP
  8. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Found an old IIS5 - same settings. Make sure that "The exact URL entered above" is checked. Otherwise you will end up redirecting requests as I described in before in this thread.

    J.D.
     
    J.D., May 9, 2005 IP
  9. Dji-man

    Dji-man Peon

    Messages:
    185
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    thanks a lot,

    I'm sending your explainations to our network admin. I hope he'll understand. ;o)
     
    Dji-man, May 9, 2005 IP
  10. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Sigh... I got this bad rep on this post:

    "You said the exact same thing mopacfan said three posts earlier."

    In my response I clarified which checkbox needs to be checked for this type of redirection to work. If you just follow mopacfan's instructions, you will not redirect all requests to the same page.

    My advice to whoever it was - learn to read people's posts carefully before judging.

    J.D.
     
    J.D., May 9, 2005 IP
  11. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #11
    INstead of redirecting for all those pages, since you are sending them all to the home page anyway, just delete all the old pages and do a custom 404 that does a 301 redirect to the home page.
     
    iShopHQ, May 10, 2005 IP
  12. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #12
    This is true. I forgot to mention the check boxes down below. :eek:
     
    mopacfan, May 10, 2005 IP
  13. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #13
    You can still delete the pages from the server's hard drive. IIS won't need them anymore once the redirect is established.
     
    mopacfan, May 10, 2005 IP
  14. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Using custom 404 makes sense *only* if your hosting company doesn't let you do this kind of thing the right way (i.e. using IIS configuration). Those who will use this trick need to make sure that the response code is changed programmatically from 404 to 301 in the custom 404 response.

    J.D.
     
    J.D., May 10, 2005 IP