简体   繁体   English

使用自定义路径提取从子目录到子域的IIS URL重写模式

[英]IIS URL Rewrite pattern from subdirectory to subdomain with custom path extraction

Previously there was this... 以前有这个...

http://www.website.com/blog/post/2013/04/16/Animal-Kingdom 's-Wild-Africa-Trek.aspx http://www.website.com/blog/post/2013/04/16/Animal-Kingdom's-Wild-Africa-Trek.aspx

(notice the apostrophe in 'Kingdom's') (请注意“王国”中的撇号)

and its now located at: 现在位于:

http://blog.website.com/post/Animal-Kingdoms-Wild-Africa-Trek http://blog.website.com/post/Animal-Kingdoms-Wild-Africa-Trek

so, breaking it down the parts are... 因此,将其分解为...

remove .aspx from the end of the URL map the call from www. 从URL末尾删除.aspx映射来自www的呼叫。 to blog. 博客。 and remove the blog part of the path remove the date from the URL remove the apostrophe 并删除路径中的博客部分从URL中删除日期删除撇号

I understand how to redirect the subdirectory to a subdomain, but im stuck extracting the other parts of the path correctly, and cleaning out the apostrophe too. 我知道如何将子目录重定向到子域,但是我无法正确提取路径的其他部分,并且也要清除撇号。

A complete solution would be a great help, thanks in advance. 预先感谢您,一个完整的解决方案将为您提供很大的帮助。

There is no way to remove all ' , because it can be more than one. 无法删除所有的' ,因为它可以多个。 You could try following regexp (it allows up to 4 apostrophes), but it is quite "danger": 您可以尝试使用regexp(最多允许4个撇号),但这确实很“危险”:

/blog/post/\d+/\d+/\d+/(([^']*)'*([^']*)'*([^']*)'*([^']*)'*).aspx

And redirect URL will be: 重定向URL将为:

http://blog.website.com/post/{R:2}{R:3}{R:4}{R:5}

Bellow screenshot of my IIS Rule: 我的IIS规则的贝娄屏幕截图: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM