【问题标题】:DNN UrlRewrite ("DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules") does not run custom rewrite rule on web.configDNN UrlRewrite ("DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules") 不在 web.config 上运行自定义重写规则
【发布时间】:2020-08-04 20:04:41
【问题描述】:

在托管在 Azure 应用服务中的 DNN 站点上,我们在 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://(ourazure webapp.com)/base3/index.html) 时,我们不断收到错误 您要查找的资源已被删除,名称已更改,或暂时不可用。这令人困惑,因为这是我们在其他网站上使用的重写规则。

我们甚至在新的应用服务上尝试了相同的方法,上面的重写规则运行良好..

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

<system.webServer> <modules runAllManagedModulesForAllRequests="true">下 然后评论&lt;add name="UrlRewrite" type="DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules" preCondition="managedHandler" /&gt;

但是,主站点现在中断了..

我们如何实现适用于DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules 的重写规则?

【问题讨论】:

  • 可以先尝试部署在本地IIS上,安装好url重写模块后,看看是否生效,保证程序正确。
  • 嗨@Jason,听从了你的建议,是的,重写工作正常。此重写也在另一个 azure app 服务中设置。你对处理这个问题有什么建议?
  • 我还发现 url 重写在 azure 中不起作用。也许你可以使用应用网关来设置url重写的规则。^_^

标签: azure-web-app-service dotnetnuke


【解决方案1】:

更新

 <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无法完全控制。您可以在另一个post 中参考我的答案。

您可以使用应用程序网关来实现url重写功能。

【讨论】:

  • 这很有趣......好吧,我们将检查应用程序网关
  • @MalcolmSalvador 我还发现 Azure Front Door 有 url rewrite 的功能,你可以看到它。 docs.microsoft.com/en-us/azure/frontdoor/front-door-url-rewrite
  • 嗨@Jason,但奇怪的是,在我们的其他 DNN 站点上,我们为执行反向代理所做的重写规则有效,但不知何故,对于这个站点,它没有......尝试这两种想法,并会做出回应这是我们实施的最终解决方案
  • @MalcolmSalvadorm Okey,我已经更新了我的答案。我还在 azure 中部署了我的演示。 url rewrite功能好像在我的demo中生效了。
  • @MalcolmSalvador 你可以试试,修改你的web.config。
猜你喜欢
  • 1970-01-01
  • 2019-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-23
相关资源
最近更新 更多