URL Redirect

Stevie Zakhour
Stevie Zakhour used Ask the Experts™
on
Hi All

I'm using a Windows Server 2012 R2 Standard with IIS Version 8.5.9600. I'm trying to redirect link A to link B, see below

Link A
ifly.com.au/special

Open in new window


Link B
https://downunder.iflyworld.com/book-now/gifting-step3-special?code=BLOCKS&tunnel=PEN

Open in new window


I created a web.config file under the iFLY.com.au folder, the web.config consists of the below

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
<httpRedirect destination="https://downunder.iflyworld.com/book-now/gifting-step3-special?code=BLOCKS&tunnel=PEN"/>
    </system.webServer>
</configuration>

Open in new window


When I try to access the iFLY.com.au/special I get the
500 - Internal server error.

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

Open in new window


Any help is greatly appreciated!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
mccarlIT Business Systems Analyst / Software Developer
Top Expert 2015

Commented:
the <httpRedirect> element has an attribule "enabled" that is false by default, so for anything to work you would have to include...

enabled="true"

Also, though I'm not sure how this redirect is targeting the    /special    link as you said that you are putting this web.config in the websites root directory? Should you have a <location> element surrounding the <httpRedirect> so that it targets just the  /special link?
Thanks Mccarl.

I have resolved this, below is what I used in the web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                    <match url="^book-now/gifting-step3-special$" />
                    <conditions>
                        <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                        <add input="{QUERY_STRING}" pattern="^code=([^=&amp;]+)&amp;tunnel=([^=&amp;]+)$" />
                    </conditions>
                    <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
                </rule>
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^([^/]+)/([^/]+)/?$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="book-now/gifting-step3-special?code={R:1}&amp;tunnel={R:2}" />
                </rule>
            </rules>
            <outboundRules>
                <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^(.*/)book-now/gifting-step3-special\?code=([^=&amp;]+)&amp;(?:amp;)?tunnel=([^=&amp;]+)$" />
                    <action type="Rewrite" value="{R:1}{R:2}/{R:3}/" />
                </rule>
            </outboundRules>
        </rewrite>
        <httpRedirect destination="https://downunder.iflyworld.com/book-now/gifting-step3-special?code=BLOCKS&amp;tunnel=PEN" />
    </system.webServer>
</configuration>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial