« Previous Next »

Thread: IIS7 rewrite to insert a new vdir

Last post 10-29-2009 8:08 PM by anilr. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 10-27-2009, 4:54 PM

    • iis9002
    • Not Ranked
    • Joined on 10-27-2009, 8:44 PM
    • Posts 2

    IIS7 rewrite to insert a new vdir

    Hey, assume I have a site http://foo.com/anypath/..., how do I rewrite it to http://foo.com/temp/anypath...

    Here is the rule I have for now.

    <rule name="test" stopProcessing="true">
                        <match url="^(?!.*temp).*$" /><!--
                        <action type="Rewrite" url="/temp/" appendQueryString="true" />
    </rule>

    Basically, I need to insert "temp" right after the host while preserving everything else (both relative path and parameter). I can not hardcode "anypath", as it is unknown to me; also.

    Thanks

  • 10-27-2009, 6:43 PM In reply to

    • iis9002
    • Not Ranked
    • Joined on 10-27-2009, 8:44 PM
    • Posts 2

    Re: IIS7 rewrite to insert a new vdir

    Have answer for myself

    <action type="Rewrite" url="temp/{PATH_INFO}" appendQueryString="true" />

    But weired thing is if I go to http://foo.com/anypath, sometimes, it is correct, but sometimes it redirects to http://foo.com/temp/anypath, especially after I clear cache. Could this be a bug in IIS or am I missing sth here

  • 10-29-2009, 8:08 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: IIS7 rewrite to insert a new vdir

    {PATH_INFO} for a request may not be the whole url based on what handler it is mapped to - you should probably use either {R:0} or {URL}

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
Page 1 of 1 (3 items)
Microsoft Communities