关于在Webconfig中定义301重定向时正则表达式如何写

weixin_44336905 weixin_44336905 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我原来是在web.config中定义了每一个网址的重定向去向,但是超过了1000左右重定向就出现错误了,但是我要重定向的页面有3000多个,但是这些文件目录下只有部分文件需要重定向,因此不能用目录重定向的方式。我原来的方法如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="17276" stopProcessing="true">
<match url="^cs_17276.html" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="https://www.xxx.com/xxx/h/17276.html" redirectType="Permanent"/>
</rule>
<rule name="17271" stopProcessing="true">
<match url="^cs_17271.html" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="https://math.xxx.com/xxx/h/17271.html" redirectType="Permanent"/>
</rule>
...
</rules>
</rewrite>
</system.webServer>
</configuration>

我需要实现一个目录下某些文件定向到相应的网站去,在webconfig里的一个rule中如何用正则表达式来写呢?
如:
1、cs_17276.html、cs_17286.html、cs_17476.html...。分别定向到:https://www.xxx.com/xxx/h/17276.html、https://www.xxx.com/xxx/h/17286.html、https://www.xxx.com/xxx/h/17476.html
2、cs_17273.html、cs_17282.html、cs_17471.html...。分别定向到:https://www.xxx.com/xxx/w/17273.html、https://www.xxx.com/xxx/w/17282.html、https://www.xxx.com/xxx/w/17471.html
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
weixin_44336905
.NET社区 62,272 成员 668,968 内容