Kadir Çetintaş
Kadir Çetintaş

Reputation: 207

IIS / MVC web.config rewrite

I have two projects on my server on running at same ip.

  1. a.company.com (MVC)
  2. b.company.com (WEBAPI)

I want to redirect; a.company.com/api/(.*) => **b.company.com/(.*)

Like that, but i want to keep b.company.com hostname is hidden. Its mean i want to rewrite it, not redirect.

Thanks.

Upvotes: 0

Views: 728

Answers (1)

Bob Gear
Bob Gear

Reputation: 174

You will need to have the URL Rewrite module 2.0 loaded, which is available via the platform installer. this will allow you to do server-side URL rewriting.

I can't say exactly what your rules should be but if you do it at the site level you will get somthing like this in your web.config in the system.webServer section:

    <rewrite>
        <rules>
            <rule name="rewrite" patternSyntax="Wildcard">
                <match url="/api/*" />
                <action type="Rewrite" url="/{R:1}" />
            </rule>
        </rules>
    </rewrite>

You will need to use the correct capture groups to match your situation.

Upvotes: 1

Related Questions