Thursday, January 27, 2011

how to use iis 6.0 redirects?

I'm attempting to use the below reference to create a re-direct for my local site with no luck.

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/6b855a7a-0884-4508-ba95-079f38c77017.mspx?mfr=true

I want absolute links on my local site that point online to point to my local site instead.

example absolute link [http://online.com/products]

when I click the local version I'd like it to redirect to: [http://offline/products]

I want to preserve everything after the domain name and append it to the server (local) name so that when I click a link it will redirect to the local site and not the online version.

I've tried [http://offline$S] but that doesn't append the "suffix" /products the way I thought it should.

What's going on here?

  • An IIS redirect isn't going to work for you in this case. For those absolute links your offline IIS server is completely out of the picture. If you look in your IIS logs on offline you should see that none of those requests even make it to that server. Your browser will attempt to directly contact online.come itself and send the request there (by way of any proxy servers in the chain). IIS on offline never gets a chance to handle the request and therefore will not fire any redirect. For an IIS redirect to work the initial request must be served by your IIS server.

    To make this work you would need to get creative with dns or internal proxy servers.

    payling : I have little to no experience configuring dns or internal proxy servers. Do you think those are my only solutions other than converting links to relative?
    squillman : @payling: Yes, I do. With the added possibility of using host file entries, but that's a similar issue to creating a dns solution. The issue that you're facing is a name resolution thing which are solved by dns / hosts file entry, or by using a proxy server that knows how to forward the HTTP requests appropriately for your network environment.
    payling : I'm not sure if this helps, but the reason why I'm looking to redirect is because I created my site using SSI. The menus, footers, headers etc are all includes and must have absolute links otherwise the links will redirect to the wrong location once the user has traveled to a page in a sub directory.
    squillman : @payling no, not really. An absolute link in the markup that a client uses is just that regardless of how it's generated. The client does not interpret them differently (and has no way of distinguishing differences).
    payling : I'm currently considering an option to use SSI conditional statements to determine which url to load. The live site will always use port 80 and the local site is on 81. I could create an ssl statement that says if port 81 load local url else load absolute url.
    payling : Just realized that won't work, iis6 does not support SSI conditional statements...
    From squillman
  • Is the computer hosting the 'local' site on the same network as the IIS?

    Do you need the option to access both online and offline versions?

    payling : Yes and yes. The main site (online) is hosted off site. I setup iis6 on our internal server for development purposes so I could test it before uploading it to the live site. So I can't redirect all urls for our company to go to the local website, it's meant for just the web developers here.
    Kyle Buser : You can accomplish this in a make shift manner by assigning an IP address to the domain name in the hosts file of the computers that want to point to the offline version. On windows machines this file is generally located@ C:\Windows\System32\drivers\etc\hosts if you add 127.0.0.1 onlineurl.com (replace 127.0.0.1 with whatever the internal site IP address is.) you can do it this way. On Linux it's /etc/hosts
    From Kyle Buser
  • Is this just for your developers? I'm still a bit confused on what you're attempting to do. However you can do a few things, some already suggested.

    1. Use Host Files if you can't change DNS which will change resolution for entire company
    2. But if your developers are online ones going to offline.com - create a new local/internal DNS record (host record) for offline.com
    3. Use your redirects on offline.com for the pages where you want the links to go to live content on online.com (basically reverse of what you were thinking - since you do have control of offline.com)

    Also, for #3, instead of using iis redirects, try ISAPI rewrite tools. Since its dev, i'm sure you don't want to pay for one - (one i use is Helicon - isapirewrite .com [won't let me post more hyperlinks] $99 /server) but there are free ones - IIRF http://iirf.codeplex.com/ might be a good choice.

    payling : I'll have to look into ISAPI rewrite tools, sounds promising!
    From nurealm

0 comments:

Post a Comment