How to redirect url to subdirectory on iis 2012 [Answered]RSS

1 reply

Last post Sep 05, 2019 07:02 AM by Jalpa Panchal

  • How to redirect url to subdirectory on iis 2012

    Sep 04, 2019 09:07 PM|hot1304|LINK

    I would like to redirect users a subdirectory, for exemplo... if the user get on mysite.com/blog they go to a wordpress page. If the user go to mysite.com they go to a store page. I've tried to make a virtual directory but it wasn't success, it shows a blank page with no information. 

  • Re: How to redirect url to subdirectory on iis 2012

    Sep 05, 2019 07:02 AM|Jalpa Panchal|LINK

    Hi,

    You could use below url rewrite rule to redirect mysite.com/blog to a WordPress page.

      <rule name="blog to wordpress" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="mysite.com" />
                            <add input="{REQUEST_URI}" pattern="/blog" />
                        </conditions>
                        <action type="Redirect" url="http://{HTTP_HOST}/wordpress.html" />
                    </rule>

    If you want to use subdirectory you could ad the subdirectory path.

    below is an example with the virtual directory.

     <rule name="blog to wordpress" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="mysite.com" />
                            <add input="{REQUEST_URI}" pattern="/blog" />
                        </conditions>
                        <action type="Redirect" url="http://{HTTP_HOST}/test/wordpress.html" />
                    </rule>

     <rule name="mysite to store" stopProcessing="true">
                        <match url="^$" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^mysite\.com$" />
                        </conditions>
                        <action type="Redirect" url="http://{HTTP_HOST}/store.html" />
                    </rule>

    with the virtual directory:

     <rule name="mysite to store" stopProcessing="true">
                        <match url="^$" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^mysite\.com$" />
                        </conditions>
                        <action type="Redirect" url="http://{HTTP_HOST}/test/store.html" />
                    </rule>

    Regards,

    Jalpa

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.