本文介绍了DNN UrlRewrite("DotNetNuke.HttpModules.UrlRewriteModule,DotNetNuke.HttpModules")不在web.config上运行自定义重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在由Azure应用服务托管的DNN网站上,我们在web.config上设置了以下自定义规则:

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>

我们还在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>

但是,当尝试导航到它时( https://(our azure webapp.com)/base3/index .html),我们不断收到错误消息您要查找的资源已被删除,名称已更改或暂时不可用.令人困惑,因为这是我们在其他资源上使用的重写规则网站.

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..

尝试通过启发式分析找出问题所在,在以下情况下,在我们的web.config上,重写规则现在可以使用:

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

然后评论<add name="UrlRewrite" type="DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules" preCondition="managedHandler" />

但是,主站点现在坏了.

However, the main site breaks now..

我们如何实现可与DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules一起正常使用的重写规则?

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

推荐答案

更新

 <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>

重要

关于url重写的功能,原因是由App Service集成的Web Server无法完全控制.您可以在其他帖子中引用我的答案.

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 .

您可以使用Application Gateway来实现url重写功能.

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

这篇关于DNN UrlRewrite("DotNetNuke.HttpModules.UrlRewriteModule,DotNetNuke.HttpModules")不在web.config上运行自定义重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:05