views:

199

answers:

1

I have a REST service and am trying to remove the .svc - a common task/problem.

The application on the server is in a virtual directory under the default website (not sure if this is important)

I have installed the IIS Rewrite Module and have tried to create a rewrite rule for this.

http://blah.me.com/here/thingys/get?id=1111

to rewrite to this:

http://blah.me.com/service.svc/thingys/get?id=1111

In my web.conf the following is created:

<rewrite>
        <rules>
            <rule name="GEAPI /here/ to /service.svc/">
                <match url="^(.*?)/here/(.*)$" />
                <action type="Rewrite" url="{R:1}/service.svc/{R:2}" />
            </rule>
        </rules>
    </rewrite>

In the GUI the regular expression does test correctly.

However - when I run this in a browser on the server, it gives the following 404 error:

Error Code 0x80070002
Requested URL http://blah.me.com:80/here/thingys/get?id=1111
Physical Path C:\MyApp\here\thingys\get


C:\Myapp is the correct physical directory the virtual directory in IIS is pointing to.

Is there something I am missing here ? I have tried creating this rule under both the default website and the app, both separately and together.

Big thanks

P

A: 

You could use this:

<rewrite>
    <rules>
        <rule name="GEAPI /here/ to /service.svc/">
            <match url="^(.*)here(/.+)" />
            <action type="Rewrite" url="{R:1}service.svc{R:2}" />
        </rule>
    </rules>
</rewrite>

IIS will only give you the part of the URI that's after http://blah.me.com/

Cheers, dotnetCarpenter

dotnetCarpenter