siteurls.config和url在dotnetnuke 9中重新编写

时间:2017-02-10 15:12:16

标签: asp.net url-rewriting url-routing dotnetnuke dotnetnuke-9

重写网址和人性化网址在seo和性能方面非常重要。 dnnurlprovider是DNN的默认ur rewiter,规则是在siteurls.config和DNN 9中编写的:

<?xml version="1.0" encoding="utf-8" ?>
<RewriterConfig>
    <Rules>
        <RewriterRule>
            <LookFor>.*DesktopDefault.aspx(.*)</LookFor>
            <SendTo>~/Default.aspx$1</SendTo>
        </RewriterRule>
        <RewriterRule>
            <LookFor>.*EditModule.aspx(.*)</LookFor>
            <SendTo>~/Default.aspx$1</SendTo>
        </RewriterRule>
        <RewriterRule>
            <LookFor>.*/TabId/(\d+)(.*)/Logoff.aspx</LookFor>
            <SendTo>~/Admin/Security/Logoff.aspx?tabid=$1</SendTo>
        </RewriterRule>
        <RewriterRule>
            <LookFor>.*/TabId/(\d+)(.*)/rss.aspx</LookFor>
            <SendTo>~/rss.aspx?TabId=$1</SendTo>
        </RewriterRule>
        <RewriterRule>
            <LookFor>.*Telerik.RadUploadProgressHandler.ashx(.*)</LookFor>
            <SendTo>~/Telerik.RadUploadProgressHandler.ashx$1</SendTo>
        </RewriterRule>
        <RewriterRule>
            <LookFor>[^?]*/TabId/(\d+)(.*)</LookFor>
            <SendTo>~/Default.aspx?TabId=$1</SendTo>
        </RewriterRule>
        <RewriterRule>
            <LookFor>.*BannerClickThrough.aspx(.*)</LookFor>
            <SendTo>~/DesktopModules/Admin/Banners/BannerClickThrough.aspx$1</SendTo>
        </RewriterRule>
 <RewriterRule>
            <LookFor>.*/m/(\d+)(.*)</LookFor>
            <SendTo>~/rss.aspx?TabId=$1</SendTo>
        </RewriterRule>
        </Rules>

</RewriterConfig>

现在我为新的网址格式添加了新规则:

<RewriterRule>
        <LookFor>.*/m/(\d+)(.*)</LookFor>
        <SendTo>~/Default.aspx?TabId=$1</SendTo>
    </RewriterRule>

应用程序池重新启动,并且没有错误写入日志文件夹,但重写了我添加的规则不起作用。 http://domain.com/m/123 --> http://domain.com/Default.aspx?TabId=123

此方法也已经过测试:

  1. 在我的IIS上安装了urlrewrite扩展 (http://www.iis.net/download/urlrewrite
  2. 添加了以下代码 片段到dnn网站的web.config标记: <rewrite><rules><rule name="UrlRewriteService" stopProcessing="true"><match url="^.*/m/(.*)$"/><action type="Rewrite" url="Default.aspx?TabId={R:1}" /></rule></rules></rewrite>

0 个答案:

没有答案