Change ORDS URL with IIS URL Rewrite

293 Views Asked by At

I've written a set of REST APIs (Oracle ORDS) with the URL following format: https://servername:8443/ords/schema_alias/module_name/handler_name/p1/p2

The requirement from the client is that it be in the following format (will be used by an external tool): https://servername:8443/handler_name/p1/p2

We are using IIS and I tried to achieve this with URL Rewrite:

Pattern: ^handler_name/([_0-9-]+)/([0-9]+)

Action type: Rewrite

Rewrite URL: ords/schema_alias/module_name/handler_name/{R:1}/{R:2}

The Test Pattern option in URL Rewrite worked as expected.

However when I test the URL I get a page not found (404). I am able to verify the configuration in the C:\inetpub\wwwwroot\site_name\Web.config file.

Can anyone please shed some light as to why the web server does not recognise the URL?

EDIT: additional information after @Deepak-MSFT 's Answer

Below is my rule's configuration: enter image description here

And the detailed error message: enter image description here

I have added the folder, but that did not make a difference: C:\inetpub\wwwroot\b******MS

Below are the IIS sites: enter image description here

1

There are 1 best solutions below

6
Deepak-MSFT On

I have tested below URL Rewrite rule is rewriting the URL from http://localhost:8443/handler_name/p1/p2 to http://localhost:8443/ords/schema_alias/module_name/handler_name/p1/p2

 <rewrite>
            <rules>
                <rule name="Rule-1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="localhost:8443" />
                        <add input="{REQUEST_URI}" pattern="/handler_name(.*)" />
                    </conditions>
                    <action type="Rewrite" url="ords/schema_alias/module_name/handler_name{C:1}" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>

Test Result

enter image description here

If you still get the 404 error then make sure the path in the file system is correct and folder exists.

Further, you could share the screenshot of the detailed 404 error. It could show the module name that is having issue. It could help you narrow down the issue.