1
votes

On our DNN site hosted in an Azure app service, we have the following custom rule set on our web.config:

<rewrite>
      <rules>
               <rule name="Proxy" stopProcessing="true">
                    <match url="^base3/?(.*)" />
                    <action type="Rewrite" url="https://(a website hosted in aws s3)/tx/{R:1}" />
                    <serverVariables>
                        <set name="HTTP_ACCEPT_ENCODING" value="" />
                        <set name="HTTP_X_ORIGINAL_HOST" value="{HTTP_HOST}" />
                        <set name="HTTP_X_Blog" value="1" />
                    </serverVariables>
                </rule> 

      </rules>

We have also setup the following in our applicationHost.xdt

<?xml version="1.0"?>  
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  
    <system.webServer>  
        <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />    
        <rewrite>
            <allowedServerVariables>
                <add name="HTTP_X_ORIGINAL_HOST" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
                <add name="HTTP_X_UNPROXIED_URL" xdt:Transform="Insert" xdt:Locator="Match(name)"/>                
                <add name="HTTP_ACCEPT_ENCODING" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
                <add name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" xdt:Transform="Insert" xdt:Locator="Match(name)"/>

                <add name="HTTP_X_Mischief" xdt:Transform="Insert" xdt:Locator="Match(name)"/>
                <add name="HTTP_X_Blog" xdt:Transform="Insert" xdt:Locator="Match(name)"/>

            </allowedServerVariables>
        </rewrite>
    </system.webServer>  
</configuration> 

However, when trying to navigate to it (https://(our azure webapp.com)/base3/index.html) we constantly get the error The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. which is confusing because this was the rewrite rule we have used on our other sites.

We even tried the same approach on a fresh app service and the rewrite rule above works just fine..

Trying to figure out what's wrong through heuristic analysis, on our web.config the rewrite rule now works if:

under <system.webServer> <modules runAllManagedModulesForAllRequests="true"> then commenting <add name="UrlRewrite" type="DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules" preCondition="managedHandler" />

However, the main site breaks now..

How do we implement a rewrite rule that works properly with DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules??

1
You can first try to deploy on the local IIS, after installing the url rewrite module, see if it takes effect to ensure that the program is correct.Jason Pan
hi @Jason, followed your advice and yes the rewrite is working. This rewrite is also set up in another azure app service. What is your advise on dealing with this problem?Malcolm Salvador
I also find url rewrite is not working in azure. Maybe you can use application gateway to set up the rules of url rewrite.^_^Jason Pan

1 Answers

1
votes

UPDATE

 <configSections>
     <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,URLRewriter" />
 </configSections>
 ......
 <RewriterConfig>
    <Rules>
       <RewriterRule>
         <LookFor>^default/([0-9]+)/([_0-9a-z-]+)</LookFor>
         <SendTo>11.aspx?id={R:1}</SendTo>
       </RewriterRule>
    </Rules>
 </RewriterConfig>

enter image description here

PRIVIOUS

About the function of url rewrite, the reason is the Web Server integrated by App Service cannot have full control. You can refer my answer in another post .

You can use the Application Gateway to implement the url rewriting function.