1

I found in IIS HTTP Redirect feature, but I can only redirect all incoming requests to specific destination. Is it possible to redirect incoming requests to specific URLs in IIS? For example:

my.domain.com/blog/about -> other.domainxyz.com/site/about
my.domain.com/blog/post/5 -> other.domainxyz.com/site/5

UPDATE

This is how web.config looks like:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
        <rewrite>
            <rules>
                <rule name="home" stopProcessing="true">
                    <match url="^$" />
                    <action type="Redirect" url="http://yojimbo87.github.com/" />
                </rule>
                <rule name="about" stopProcessing="true">
                    <match url="^Blog/About$" />
                    <action type="Redirect" url="http://yojimbo87.github.com/about/about.html" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I havent't found URL Rewrite module among the Role Services although HTTP Redirection is there.

2
  • Are both domains bound to the same site .. or they are 2 different sites (I'm asking if domain name should be a condition when creating a rule)?
    – LazyOne
    Jul 14, 2011 at 7:48
  • Domains are on different sites separated on different machines. I can control only the redirection on the IIS machine.
    – yojimbo87
    Jul 14, 2011 at 7:53

1 Answer 1

4

This rule will redirect SPECIFIC incoming request to specific URL:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="Redirect Specific Page" stopProcessing="true">
                <match url="^blog/post/5$" />
                <action type="Redirect" url="http://other.domainxyz.com/site/5" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

UPDATE: I have merged them together -- just update it with real URLs:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
        <rewrite>
            <rules>
                <rule name="home" stopProcessing="true">
                    <match url="^$" />
                    <action type="Redirect" url="http://yojimbo87.github.com/" />
                </rule>
                <rule name="about" stopProcessing="true">
                    <match url="^Blog/About$" />
                    <action type="Redirect" url="http://yojimbo87.github.com/about/about.html" />
                </rule>
                <rule name="Redirect Specific Page" stopProcessing="true">
                    <match url="^blog/post/5$" />
                    <action type="Redirect" url="http://other.domainxyz.com/site/5" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
8
  • When I add this into web.config inside configuration element it starts giving me "500 - Internal server error" no matter which combination of url match I use.
    – yojimbo87
    Jul 14, 2011 at 8:46
  • @yojimbo87 1) You need to have URL Rewrite module installed (which you should have already, considering "IIS 7.5" tag). 2) I hope you have not added it "as is"? If you have some rewrite rules already, then you need to add just <rule> part into appropriate place. In any case -- the rule is 100% working as I have tested it before posting. If you can -- please provide your web.config (no need for whole content -- just enough to see the structure) so I can guide you where it needs to be placed (in case it is the actual problem).
    – LazyOne
    Jul 14, 2011 at 9:07
  • Question updated.
    – yojimbo87
    Jul 14, 2011 at 9:22
  • @yojimbo87 See updated answer. If your web.config worked before it should work now as well.
    – LazyOne
    Jul 14, 2011 at 9:33
  • Still no luck. If I try to go to IIS manager and want to see Failed Request Tracing Rules it gives me an error pointing to web.config. This looks strange cause other people have also issues with it.
    – yojimbo87
    Jul 14, 2011 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .