Link to home
Start Free TrialLog in
Avatar of CLR Benjamin
CLR BenjaminFlag for France

asked on

Rewrite URL - Keep the URL from a HTML page

Hi,

I have an internal site:  http://old.intranet.contoso.fr/organigrammeFR.html

I want to redirect this URL: organigramme.contoso.com to  http://old.intranet.contoso.fr/organigrammeFR.html.

IIS server (IIS 6.1) is mounted with redirect url and it works. But in the brower old.intranet.contoso.fr/organigrammeFR.html is displayed instead of organigramme.consoto.com.

How to redirect the html page to the website and keep the new url?

Thanks in advance
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

you need both a redirect and a rewrite rule
<rule name="Proxy">  
<match url="(.*)" />  
<conditions>  
<add input="{CACHE_URL}" pattern="^(https?)://" />  
</conditions>  
<action type="Rewrite" url="{C:1}://internalserver/{R:1}" />  
</rule>  

Open in new window

Avatar of CLR Benjamin

ASKER

Thanks David,

But it doesn't work:

<rule name="Proxy">  
<match url="(.*)" />  
<conditions>  
<add input="{CACHE_URL}" pattern="^http://old.intranet.contoso.fr/organigrammeFR.html" />  
</conditions>  
<action type="Rewrite" url="{C:1}://organigramme.contoso.com{R:1}" />  
</rule>  

User generated image
User generated image
embed=file 1328241]
capt3.JPG
<rule name="Proxy">  
<match url="(.*)" />  
<conditions>  
<add input="{CACHE_URL}" pattern="^(https?)://" />  
</conditions>  
<action type="Rewrite" url="{C:1}://organigramme.contoso.com{R:1}" />  
</rule>  

I think it has to be something like this. No credits for guessing this :-)
Not working, always the same problem with this conf:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="http://org.contoso.com/" exactDestination="true" childOnly="false" httpResponseStatus="Permanent" />
        <rewrite>
            <rules>
<rule name="Proxy">  
<match url="(.*)" />  
<conditions>  
<add input="{CACHE_URL}" pattern="^(https?)://" />  
</conditions>  
<action type="Rewrite" url="{C:1}://organigramme.contoso.com{R:1}" />  
</rule> 
            </rules>
        </rewrite>
    </system.webServer>

</configuration>

Open in new window

Are you trying to pass parameters as well, then ({R:1} construct is incorrect.
Quoting from Scott Gu's blog:
The "{R:N}" regex construct, where N >= 0, is called a regular expression back-reference and N is the back-reference index. In the case of our pattern "(.*?)/?Default\.aspx$", if the input URL is "products/Default.aspx" then {R:0} will contain "products/Default.aspx" and {R:1} will contain "products".  We are going to use this {R:1}/ value to be the URL we redirect users to.

Fro more explanation see Step 3: Setup a Permanent Redirect Action in this link.
ASKER CERTIFIED SOLUTION
Avatar of CLR Benjamin
CLR Benjamin
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial