DNN UrlRewrite (“DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules”) does not run custom rewrite rule on web.config

ⅰ亾dé卋堺 提交于 2020-05-15 21:35:29

问题


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:


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>

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.



来源:https://stackoverflow.com/questions/61354328/dnn-urlrewrite-dotnetnuke-httpmodules-urlrewritemodule-dotnetnuke-httpmodules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!