iis - 使用BlogEngine进行URL重定向

标签 iis url-rewriting web-config blogengine.net

我正在将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/

相关文章:

php - 将上传文件移动到 IIS 中的另一台服务器的权限被拒绝

asp.net - 应用程序池标识或模拟

asp.net - 在启用 URL 重写的 VS 2010 中调试 ASP.NET 4.0 站点

asp.net - IIS url 重写 |如何删除目录和扩展名?

.htaccess - Htaccess - 多个参数

asp.net - 将 machineKey 添加到网络场站点上的 web.config

iis - 在 IIS7 中重写 URL

asp.net - IIS 7经典模式自定义HttpModule中的Set-MaxAge

c# - 在没有发布的情况下在完整的 IIS 中运行 ASP.NET Core 应用程序会出现 502.5 错误

c# - WCF 和 Ajax。不允许的方法让我发疯