@Mohamed Akl Thanks for reaching out. Unfortunately, there is no out of the box solution for your requirement. Please confirm if my understanding is correct that as of now you only have one product in your APIM instance with name product and you want to redirect to login page if the request comes with any other name expects product in the URL as you don’t want to show 404 error to your end user when they hit the invalid URL.
The workaround would be to create the custom policy at global level as shown in below using [When condition] (https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#choose) block. The below custom policy will validate whether the API URL contains any suffix with product in the request.
If the request doesn’t contain suffix product it will redirect to your login page. If the request contains product it will redirect the request to the backend instance.
<inbound>
<choose>
<when condition="@(context.Request.Url.Path.Contains("product") ? false : true)">
<return-response>
<set-status code="303" reason="Redirecting" />
<set-header name="Location" exists-action="override">
<value>@("https://https://www.mywebsite.com/login./")</value>
</set-header>
</return-response>
</when>
<otherwise />
</choose>
</inbound>
<backend />
<outbound />
<on-error />
</policies>
Note: The above policy is only for reference. If your API instance has more than one product, then you need to modify the above policy by adding multiple when Conditions blocks as per your business use case.
Feel free to get back to me if you have any query or concern.