重写网址和人性化网址在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
此方法也已经过测试:
<rewrite><rules><rule name="UrlRewriteService" stopProcessing="true"><match url="^.*/m/(.*)$"/><action type="Rewrite" url="Default.aspx?TabId={R:1}" /></rule></rules></rewrite>