How to redirect to an outside URL using IIS URL Rewrite

I want to use URL Rewrite to redirect a page to an outside url.  Example:  www.test.com/jar  redirects to www.google.com
I can't use http redirect because I don't want the entire site sent there, just the www.test.com/jar

I tried setting it up but the original page keeps coming up.
Brian SandtSystems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
You can use a HTTP Redirect deep within a site, no need to redirect the entire site.

1. Go into IIS Manager, expand the Server, then the Sites object.
2. Select the site you want and expand it
3. Select the directory you want to redirect
4. In the center panel, open the "HTTP Redirect" feature
5. In the "Redirect requests to this destination" field, enter the FQDN including https/https to the site you want to send the users to
6. In the Redirect behavior, from the drop-down, select the state of the redirect. (Found, Permanent or Temporary)
7. If you want only this specific URL to redirect, check the second box.  Otherwise, let both boxes unchecked, which will redirect any request to this URL and any sub-URLs.
6. Apply the change
7. Test the change.

This will only execute a redirect on this specific location in your site, not the whole site.

I use this frequently on PROD servers if there are simple structural site changes.

You can also accomplish this with URL Rewrite (setting up a redirect rule) but this method is easier to do.

Dan
0
Brian SandtSystems AdministratorAuthor Commented:
With what I'm doing I can't use HTTP Redirect.  I only want the /jar to go there but don't want anything else.  If I do this, the entire site gets redirected.  IIS is currently being used as a "pass-through" for Sitecore.  The only place I can set this up is in URL rewrite.
0
Dan McFaddenSystems EngineerCommented:
Can you post a screen shot of the site in IIS Manager, with the site expanded?

Do you want all sub content to be redirected or only a specific page?

Dan
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Brian SandtSystems AdministratorAuthor Commented:
As mentioned, IIS is only acting as a passthrough for Sitecore.  Sitecore does all the rendering of the pages itself.  
I only want someone coming in with www.test.com/jar to be redirected but everyone else www.test.com/xxxxxx to work as usual.

There isn't a specific page in IIS as it's a passthrough.
0
Dan McFaddenSystems EngineerCommented:
In the web.config, inbetween the "<system.webServer>" tags, place the following rule:

        <rewrite>
            <rules>
                <rule name="Redirect JAR" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{PATH_INFO}" pattern="/jar/" />
                    </conditions>
                    <action type="Redirect" url="https://www.bing.com/" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>

Open in new window


I recommend making a backup of the web.config before making this change.

Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dan McFaddenSystems EngineerCommented:
You will just need to change the "action" element's url attribute to the appropriate destination.

Dan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.