« Previous Next »

Answered Thread: URL Rewrite not redirecting as expected

Last post 11-16-2009 4:55 AM by rkr31. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 11-09-2009, 10:33 AM

    • rkr31
    • Top 200 Contributor
    • Joined on 05-01-2007, 6:15 AM
    • Posts 31

    URL Rewrite not redirecting as expected

     It's very possible that im doing something wrong here, but if my logic is correct the below should work.

    I want it to redirect to http://docs.win1002.vs.domain.co.uk/docs if the url entered is  http://docs.win1002.vs.domain.co.uk

    Problem is, when i enter this i simply get a redirection loop which makes sense i guess.  To get around this i put a condition prior to the one above that should ignore  http://docs.win1002.vs.domain.co.uk/docs

    Therefore, if the url entered is  http://docs.win1002.vs.domain.co.uk it will redirect to http://docs.win1002.vs.domain.co.uk/docs and because there is a condition to ignore this, should then display the page.

    Is this correct or have a got this horribly wrong?

     

     

  • 11-09-2009, 4:03 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 3:38 PM
    • Redmond, WA
    • Posts 670

    Answered Re: URL Rewrite not redirecting as expected

    If all the redirections are withing the same domain docs.win1002.vs.domain.co.uk, then there is no need to have the conditions. The rule would look similar to below:

     <rewrite>
                <rules>
                    <rule name="Redirect" stopProcessing="true">
                        <match url="^$" />
                        <action type="Redirect" url="docs/" />
                    </rule>
                </rules>
     </rewrite>

     The rule is located inside of the web.config file in the root directory of your web site.

    http://ruslany.net
  • 11-10-2009, 3:05 AM In reply to

    • rkr31
    • Top 200 Contributor
    • Joined on 05-01-2007, 6:15 AM
    • Posts 31

    Re: URL Rewrite not redirecting as expected

    ok. I see where you are coming from. Is there however a way of hiding the docs folder so that the user will not see it in their browser? Users have the domain domain.com (with www.domain.com also forwarding to the same place). We want to allow them to have docs.domain.com redirect to a folder or application called docs without the user knowing that they are in a sub folder. so that if the user enters docs.domain.com it actually goes to www.domain.com/docs but the user will only see docs.domain.com in their address bar.
  • 11-12-2009, 2:31 AM In reply to

    Answered Re: URL Rewrite not redirecting as expected

    Hi,

    rkr31:
    so that if the user enters docs.domain.com it actually goes to www.domain.com/docs but the user will only see docs.domain.com in their address bar.
    If the docs.domain.com and www.domain.com are pointed to the same website on a server, then this can be archived by using URL Rewrite. The rule looks like:

    rewrite>
          <rules>
            <rule name="Rewrite to sub directory " stopProcessing="true">
              <match url=".*" />
              <conditions>
                <add input="{HTTP_HOST}" pattern="^docs.domain.com$" />
              </conditions>
              <action type="Rewrite" url="docs/{R:0}" />
            </rule>
          </rules>
    </rewrite>

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 11-16-2009, 4:55 AM In reply to

    • rkr31
    • Top 200 Contributor
    • Joined on 05-01-2007, 6:15 AM
    • Posts 31

    Re: URL Rewrite not redirecting as expected

    Thanks.  That worked perfectly :o)

Page 1 of 1 (5 items)
Microsoft Communities