Web.config匹配和将URL从根文件重定向到文件夹
我将博客文章从网站的根源转移到文件夹中。我想在我的网站的web.config中包含一个规则,该规则将帖子从其旧的根位置永久性地重定向到新文件夹位置。
所有帖子均具有以下表单的文件名,我的网站上没有其他文件,并且在新文件夹位置中的文件名与在旧的根部位置相同:
rojr ####。htm 或 rojr #### - #。htm
作为web.config和Regex的新手,我也在努力准确地编码匹配URL的模式作为重定向URL的模式。
我当前的代码是:
<rule name="redirect ROJR" stopProcessing="true">
<match url="^(ROJR\d\d\d\d-?\d?\.htm)$" ignoreCase="true" />
<action type="Redirect" url="^OJRU\/{R:1}" redirectType="Permanent" />
</rule>
这是我的问题:
匹配URL:我是否准确地描述了模式?对于先前位于root中的帖子(并且在Ojru文件夹中找不到相同名称的移动帖子),图案外观 是否会 ?
重定向的URL:我是否将旧URL重定向到新位置?
来自:example.com/rojr###-#.htm
到:example.com/ojru/rojr####-#.htm
和
来自:example.com/rojr###.htm
到:example.com/ojru/rojr ####。htm
感谢您的帮助。
I moved my blog posts from the root of my website to a folder. I want to include a rule in my site's web.config that redirects permanently the posts from their old root location to the new folder location.
All posts have filenames of the following form, a form no other files on my website have, and the filenames are the same in the new folder location as they were in the old root location:
ROJR####.htm or ROJR####-#.htm
As a newbie to both web.config and regex, I am struggling to code accurately the pattern for the match url, as well as the pattern for the redirected url.
My current code is:
<rule name="redirect ROJR" stopProcessing="true">
<match url="^(ROJR\d\d\d\d-?\d?\.htm)quot; ignoreCase="true" />
<action type="Redirect" url="^OJRU\/{R:1}" redirectType="Permanent" />
</rule>
Here are my questions:
Match URL: Did I accurately describe the pattern? And will the pattern look only for posts previously located in the root (and not find the moved posts with the same name in the OJRU folder)?
Redirected URL: Did I redirect accurately the old URLs to the new location?
FROM: example.com/ROJR####-#.htm
TO: example.com/OJRU/ROJR####-#.htm
and
FROM: example.com/ROJR####.htm
TO: example.com/OJRU/ROJR####.htm
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论