• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 52
  • Last Modified:

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.
0
Brian Sandt
Asked:
Brian Sandt
  • 4
  • 2
1 Solution
 
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
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
 
Dan McFaddenSystems EngineerCommented:
You will just need to change the "action" element's url attribute to the appropriate destination.

Dan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now