Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: IIS URL Rewrite Instructions

...

SettingValue
TypeGlobal
Base virtual path 
Virtual path^/api(\/)(.*)$
If this rule matchesPerform an internal redirection
Destination/api/cgi-bin/oecgi4.exe/$2
Next actionStop matching

IIS

Dedicated API site Domain or Subdomain

When setting up a website dedicated to host the API endpoint (i.e. api.example.com ) follow these steps:

  1. Place OECGI4.exe in the website root directory so it is accessible using the path api.example.com/oecgi4.exe
  2. Create the following URL Rewrite rules in the root directory:
SettingValue
Match URL^api$
Action typeRewrite
Action URLoecgi4.exe
Stop processing after matchChecked
SettingValue
Match URL^api([_0-9a-z-/]+)$
Action typeRewrite
Action URLoecgi4.exe/{R:1}
Stop processing after matchChecked

Or you can copy and paste these rules directly into the IIS web.config file:

<rule name="Root API" stopProcessing="true">
<match url="^api$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="oecgi4.exe" />
</rule>
<rule name="API" stopProcessing="true">
<match url="^api([_0-9a-z-/]+)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="oecgi4.exe/{R:1}" />
</rule>

Your API will be accessible by two URLs. The primary URL for your API will be www.example.com/api but you you can access www.example.com/oecgi4.exe/ to bypass the URL rewrite rules which may be useful to do as a troubleshooting step.

Adding an API to an Existing Site

When adding an API endpoint to an existing IIS site using a virtual directory (i.e. www.example.com/api ) follow these steps:

  1. On the web server copy OECGI4.exe into a separate directory to be used as a CGI directory such as C:\revsoft\oecgiapi
  2. In the website root directory create a virtual directory named oecgiapi pointing to c:\revsoft\oecgiapi. OECGI should be accessible using the url www.example.com/oecgiapi/oecgi4.exe
    IMPORTANT: The virtual directory name should not be the same name as the virtual directory name. If your virtual directory name and API name are the same the IIS rewrite rules will require additional configuration to prevent IIS from ignoring the rewrite rules. This is outside the scope of the basic configuration guide contained below.
  3. Create the following URL Rewrite rules in the root site directory:
SettingValue
Match URL^api$
Action typeRewrite
Action URLoecgiapi/oecgi4.exe
Stop processing after matchChecked
SettingValue
Match URL^api([_0-9a-z-/]+)$
Action typeRewrite
Action URLoecgiapi/oecgi4.exe/{R:1}
Stop processing after matchChecked

Or you can copy and paste these rules directly into the IIS web.config file:

<rule name="Root API" enabled="false" stopProcessing="true">
<match url="^api$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="oecgiapi/oecgi4.exe" />
</rule>
<rule name="API" enabled="false" stopProcessing="true">
<match url="^api([_0-9a-z-/]+)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="oecgiapi/oecgi4.exe/{R:1}" />
</rule>

Your API will be accessible by two URLs. The primary URL for your API will be www.example.com/api but you you can access www.example.com/oecgiapi/oecgi4.exe/ to bypass the URL rewrite rules which may be useful to do as a troubleshooting step.

 

Apache

<IfModule mod_rewrite.c>

...