在潜台词文章中添加个性化网址
所以我在 IIS6 和 .net 2.0 框架上运行 subtext 1.95。 我想做的是为潜文本系统中发布的特定文章创建一个漂亮的虚荣 URL。 虚荣网址应如下所示:mydomain.com/blog/toc/,但它指向的潜文本文章实际上具有如下路径:mydomain.com/blog/archive/2009/01/11/table-of -contents.aspx
我可能可以在 IIS 中设置转发来执行此操作,但我正在寻找一种更优雅的解决方案,不需要任何类似的自定义 IIS 配置。 我也想避免更改任何潜台词核心代码,为自己留下升级路径。
最好的解决方案是将 default.aspx 文件放入 /toc/ 文件夹中并将该页面转发到长路径吗?
提前致谢!
So I'm running subtext 1.95 on IIS6 and .net 2.0 framework. What I'd like to do is create a nice vanity URL to a particular article that is published inside the subtext system. The vanity url should look like this: mydomain.com/blog/toc/, but the subtext article that it is pointing to actually has a path like this: mydomain.com/blog/archive/2009/01/11/table-of-contents.aspx
I can probably just set up a forward within IIS to do this, but I'm looking for a more elegant solution that doesn't require any custom IIS configurations like that. I'd also like to refrain from changing any of the subtext core code, as to leave an upgrade path for myself.
Is the best solution to just put a default.aspx file inside the /toc/ folder and have that page forward on to the long path?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请注意,这适用于 Subtext 2.1.2 及更低版本
URL 匹配在 Web.config 中处理。 您可以搜索如下所示的行:
并更改那里的正则表达式。 不幸的是,Subtext 将继续生成旧链接。 在即将推出的 Subtext 2.5 中,情况略有改善。
另一个问题是,对于 IIS 6,除非 /toc/ 目录实际存在,否则 IIS 不会将请求移交给 ASP.NET,因此您需要使用通配符映射才能真正实现该操作。
目前,我认为您可能需要通过 IIS 中的某种 URL 重写 isapi 过滤器来实现此目的,以达到您想要的效果。
Note, this applies to Subtext 2.1.2 and below
URL matching is handled in Web.config. You can search for a line that looks like this:
And change the regex there. Unfortunately, Subtext will continue to generate the old links. In the upcoming Subtext 2.5, the situation improves slightly.
One other problem is that with IIS 6, unless the /toc/ directory physically exists, IIS won't hand off the request to ASP.NET, so you'd need to use wildcard mapping to actually make that work.
For now, I think you might need to do this via some sort of URL rewriting isapi filter in IIS to achieve exactly what you want.
感谢菲尔提供的信息。
我最终只创建了一个 /toc/ 文件夹,并有一个重定向到博客文章的 default.aspx 文件。 这可能是最简单的解决方案,只花了我一分钟就实现了。
Thanks for the information Phil.
I ended up just creating a /toc/ folder, and having a default.aspx file that redirects to the blog article. This is probably the easiest solution, and only took me a minute to implement.