Web.config匹配和将URL从根文件重定向到文件夹

发布于 2025-01-25 16:27:52 字数 874 浏览 4 评论 0原文

我将博客文章从网站的根源转移到文件夹中。我想在我的网站的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文