我正在将Blog从dasBlog迁移到BlogEngine。在dasBlog中,我的网址如下所示。
http://pfsolutions-mi.com/blog/2008/03/08/Beyond-Compare.aspx
而在BlogEngine中,我的URL看起来像这样。
http://pfsolutions-mi.com/blog/post/2008/03/08/Beyond-Compare.aspx
这两个URL之间唯一的区别是BlogEngine中的“ post”子文件夹。
由于我当前正在使用IIS URL Rewrite从URL中删除WWW,因此我认为最简单的解决方案是创建另一个规则来处理添加子文件夹。我尝试过这样的事情。
规则名称=“ Blog Redirect” enabled =“ true” stopProcessing =“ true”
匹配url =“ ^ blog /([[_ 0-9] +)/([_ 0-9] +)/([_ 0-9] +)/([_ 0_0a-z-] +)。([_ 0- 9a-z-] +)$“
操作type =“ Redirect” url =“ blog / post / {R:1} / {R:2} / {R:3} / {R:4}。{R:5}” redirectType =“ Temporary”
但是,当我输入旧的dasBlog URL时,它不会被重定向到新位置。相反,我得到了通用的BlogEngine 404错误页面。
注意:一旦知道一切正常,我计划将redirectType更改为Permanent。
最佳答案
您匹配的正则表达式不应该看起来像这样吗?
match url="^blog/([0-9]+)/([0-9]+)/([0-9]+)/([\w-]+)\.([a-z]+)$"
无论如何,日期编号中都没有下划线,并且您的
[_0-9a-z-]+
不包含大写字母,例如“超越比较”中的字母。因此,这里我们应该有:url =“ ^ blog / digits / digits / digits / any-word-characters.lowercase-letters $”
我们还可以通过以下方式指定更多内容:
match url="^blog/([0-9]{2,4})/([0-9]{2})/([0-9]{2})/([\w-]+)\.([a-z]{3,4})$"
基于以下假设:
年份为“ 08”或“ 2008”
月和日为“ 01”或“ 11”
文件结尾为3或4个小写字母(htm,html,php,asp,aspx等)
编辑:我认为“ \ w +”不包含连字符,因此您必须将其转换为“ [\ w-] +”
关于iis - 使用BlogEngine进行URL重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10450478/