I have a somewhat strange request: we need to rewrite a single url (eg: https://inbound.domain.com/index.php) to another (eg: http://outbound.local.com/register.php)

Any other request for a page should ideally be dropped..

This internal page references other resources on the same server (eg images are located in outbound.local.com/images/.

We have other sites running fine through URL rewrite, but I can't figure out how to filter/limit for a single page...

I tried setting inbound pattern to "https://inbound.domain.com/index.php" and rewrite URl to "http://outbound.local.com/register.php" but this ends up in a 404 not found..

We're running IIS10/url rewrite 2.0

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="https://inbound.domain.com/index.php" />
                    <action type="Rewrite" url="http://outbound.local.com/register.php" appendQueryString="false" logRewrittenUrl="true" />
                        <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
                        <set name="HTTP_ACCEPT_ENCODING" value="" />
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://outbound.local.com/(.*)" />
                    <action type="Rewrite" value="https://inbound.domain.com/{R:2}" />
                <rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
                    <match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
                    <action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
                <rule name="Deal with href tags" preCondition="ResponseIsHtml1">
                    <match filterByTags="None" pattern="href=(.*?)http://outbound.local.com/(.*?)\s" />
                    <action type="Rewrite" value="href={R:1}https://inbound.domain.com/{R:2}" />
                <rule name="Deal with action tags" preCondition="ResponseIsHtml1">
                    <match filterByTags="None" pattern="action=(.*?)http://outbound.local.com/(.*?)\\" />
                    <action type="Rewrite" value="action={R:1}https://inbound.domain.com/{R:2}\" />
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
                    <preCondition name="NeedsRestoringAcceptEncoding">
                        <add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />

1 Answer 1


You should not use the "Rewrite" action because it's a "server-side" rewrite.

You want a "Redirect" action to instruct the client (the browser) to re-connect to another URL.

For testing purposes, don't use the 301 – Permanent redirectType because the browser will cache this reponse and you'll need to empty the cache in case you did a mistake. Use 302 - Found for example

Additionally,ensure that the "match" is working, I think it should be "index.php" or "/index.php" instead of the full URL

  • Redirect woudn't work, as the internal site is located on our internal network.. Feb 13, 2020 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.