locked
Url redirection headache RRS feed

  • Question

  • User-718335335 posted

    Hi All.

    I hope anyone could help me...

    We had iis6 and everything works fine with the redirection. Now we upgrade to iis 7 and it`s a disaster. We trying to work with pattern like we used to but nothing works.

    Short desc... we have main site and also we have redirection by domain which mean when someone type e.g. www.gogo.com it redirect to www.gogo.com/redir.aspx?w=gogo and it doesn`t work.

    Till now,for each one of this domains i created a different site and create the redirection.. With the new iis it doesn`t work.

    Please, anyone can help me with it???

     

    Thursday, August 27, 2009 7:57 AM

Answers

  • User-1637866776 posted

    I would suggest to consider switching to using URL Rewrite module instead of the built-in HTTP redirection module. The rewrite module provides much more flexible functionality to perform redirection. Here are some of the examples: http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/

     For your specific case the redirect rule may look as below:

                    <rule name="redirect" >
                        <match url="^lbl/(.*)" />
                        <conditions >
                            <add input="{HTTP_HOST}" pattern="^www\.mysite\.com$" />
                        </conditions>
                        <action type="Redirect" url="wlredir.aspx?w={R:1}" redirectType="Permanent" />
                    </rule>

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Monday, August 31, 2009 1:44 PM

All replies

  • User511787461 posted

    Can you provide the exact configuration you were using in IIS6 and the configuration you have tried in IIS7 for the redirection?

    Thursday, August 27, 2009 12:54 PM
  • User-718335335 posted

    For the 1 method of redirection we have virtual directory and we used:

    Redirection to URL: *;  /*; /wlredir.aspx?W=$0

    we used this way to redirect users to white label:

    if the user for example typed:  www.mysite.com/lbl/atol the system redirected it to: www.mysite.com/wlredir.aspx?w=atol

     

     

    Sunday, August 30, 2009 2:46 AM
  • User-1637866776 posted

    I would suggest to consider switching to using URL Rewrite module instead of the built-in HTTP redirection module. The rewrite module provides much more flexible functionality to perform redirection. Here are some of the examples: http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/

     For your specific case the redirect rule may look as below:

                    <rule name="redirect" >
                        <match url="^lbl/(.*)" />
                        <conditions >
                            <add input="{HTTP_HOST}" pattern="^www\.mysite\.com$" />
                        </conditions>
                        <action type="Redirect" url="wlredir.aspx?w={R:1}" redirectType="Permanent" />
                    </rule>

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Monday, August 31, 2009 1:44 PM
  • User-1084766864 posted
    Hello ruslany, I looked at your blog and and tried to implement tip #7 but i'm running into some problems. The best result i had so far was having ALL requests sent to my server being redirected to another site on my server which is not what i want. I've installed an application on my server which runs under it's own web server. In order to use it i either need to put it on a non-standard port or i need to dedicate an IP to it. i dont want to dedicate an IP and i'd prefer if it were reachable through port 80 to avoid any firewall issues. I tried following your tip #7. I enabled the proxy checkbox in the app routing settings. It then wanted a proxy server. I wasnt sure what to put there so i put http://127.0.0.1:8081 which is the url the other app is running under. And this worked, except all requests are being sent to this site. So in the pattern for the app_server_proxy rule i changed the pattern from * to http://www.mydomain.com/ but that didn't work. The best i have been able to do is redirect ALL the traffic for my server to this app, when i only want traffic to www.mydomain.com redirected. OR it appears to get in an endless re-direct loop. can you offer some advice as to how to get this working? or point me to a link that explains it? thanks
    Monday, September 7, 2009 5:54 PM
  • User-1637866776 posted

    You need to modify the rule to be more specific and only forward requests that were for http://www.mydomain.com. Here is how you can do it:

     <rule name="Proxy">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www\.mydomain\.com$"/>
      </conditions>
      <action type="Rewrite" url="http://127.0.0.1:8081/{R:1}" />
    </rule>

    Tuesday, September 8, 2009 2:45 PM
  • User-1084766864 posted
    Thanks for the reply ruslany. Please assume i know nothing about ARR, because i dont :) I do not know where i would put this rule. What file do i modify? I've been doing everything though the GUI. is there a good doc that explains all this, because i really would like a better understanding of what's going on here before i start moving any live sites to this server? I finally did manage to get it working but i am unclear on a few issues. i got it working by turning on the proxy option in the ARR settings for the server. I enabled the 'use url rewrite' option and put 127.0.0.1:8081 as the proxy. Then i modified the ARR_server_proxy rewrite rule with: pattern: * condition: HTTP_POST = www.mydomain.com rewrite url: http://127.0.0.1:8081/{R:0} and this works. I then tried to modify this to create a rewrite rule on a site level rather then a server level. I disabled the 'use url to rewrite' option and then created the same rule on the site level. This worked with the exception that the images on my application would not load. They would instead redirect you to the login page. This behavior did not happen when i was using the server-wide rule. You can view the behavior by going to the following two URL's: help.smarttrac.com - this is using the server-wide rule. u15355163.onlinehome-server.com that url is the one where i set a rewrite rule on the site level and you'll notice the logo in the upper left corner is broken. if you try to load the graphic image directly you get redirected to the login page. This does not happen with the first url. I dont understand what difference between the server-wide rewrite verse a site-wide rewrite would cause this. thanks for the help
    Tuesday, September 8, 2009 3:13 PM
  • User-1637866776 posted

    When I try to go to either help.smarttrac.com or to uXXXXX.onlinehome-server.com in both cases I am redirected to the helpdesk logon page: http://help.smarttrac.com/helpdesk/WebObjects/Helpdesk  http://u15355163.onlinehome-server.com/helpdesk/WebObjects/Helpdesk

    This article explains how to configure URL Rewrite and ARR for reverse proxy: http://learn.iis.net/page.aspx/659/reverse-proxy-with-url-rewrite-v2-and-application-request-routing/

    The main difference between the server-wide rules and site-wide rules is that server-wide rules are applied to all the sites on the server, while the site-wide rules are applied only to a particular site. More information about it here: http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/#Rewrite_Rules_Scope

    Tuesday, September 8, 2009 3:26 PM
  • User-1084766864 posted
    thanks again. I did notice one problem with the address http://u15355163.onlinehome-server.com The logo image is broken. This is the site that is using a site-specific rule. I can not figure out why for that site the logo image is broken. I used fiddler to monitor the request from the browser and something interesting happens. On the first request i get the image. On the 2nd request instead of the image the server returns an html file which is basically redirecting me to login page. 3rd request i get the image, 4th request i got the login etc etc That only happens when fiddler is running. if i close fiddler, i get the broken image each and every time UNLESS i force IE to not use the cache, then i get the correct image file. I've got no clue why this behavior applies just to the http://u15355163.onlinehome-server.com site and not to the help.smarttrac.com site. The only difference between them is the u1... site is using a site specific url rewrite and the help site is using the server wide rewrite. I'll look over the links you provided. Thanks for the help.
    Tuesday, September 8, 2009 7:08 PM
  • User-1084766864 posted
    I've discovered another problem with the url rewrite. http://help.smarttrac.com/helpdesk/WebObjects/Helpdesk If you go to that page, and view the source code, you'll see at the top of the page 3 js files that are linked to. None of those 3 links work. In fact, the url rewrite for those links fails entirely because it's IIS that's returning a 404 message. The actual server thats returning content for that site is an apache server. if that link really were invalid (its not) then apache should be the one returnng the 404 error, not IIS. The link for the js file looks like this: http://help.smarttrac.com/helpdesk/WebObjects/Helpdesk.woa/wr/wodata=/C:/Program+Files+(x86)/WebHelpDesk/bin/webapps/helpdesk/WEB-INF/Library/Frameworks/Ajax.framework/WebServerResources/prototype.js I found some very strange behavior - if i chop off parts of that URL, i either get a 404 error from IIS, a blank page, or a 404 error from apache. I have no idea at all why IIS is returning a 404 and i can not find a pattern as to what URLs give me the iis404, a blank page or an apache 404 error. Do you have any clues why this might be happening?
    Friday, September 11, 2009 1:52 PM
  • User511787461 posted

    Can you collect failed request trace logs on the IIS server for both those issues - please make sure that the Rewrite area is selected for your trace rule (if the area does not appear, you would need to run repair for URL rewriter).  You can e-mail me the trace logs at anil (dot) ruia (at) microsoft (dot) com

    Monday, September 14, 2009 12:46 PM
  • User-1084766864 posted
    actually, someone just got it working for me just a few minutes ago. There were two issues: 1. apache apparently uses double escaping the the ARR did not. I enabled this in the settings. 2. i did not realize BIN was a special 'word' for IIS. I had to disable that in the request filtering. Now it all seems to be working.
    Monday, September 14, 2009 1:07 PM