web.config old url to new url redirects [英] web.config old url to new url redirects

查看:90
本文介绍了web.config old url to new url redirects的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有来自旧网站的大约12000个网址,需要重定向到新网站,相同的域名,相同的ID,但不同的文件夹。
我创建了一个静态rewriteMaps.config文件,这里是我的旧网址和新网址的示例

I have about 12000 URL's from an old site that need to redirect to a new site, same domain name, same id, but different folders. i created a static rewriteMaps.config file, Here's a sample of my old and new urls

<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/4935/apple-iphone-event-what-to-expect" value="/Node/d/4946" />
<add key="/4936/twitter-tablet-android-app-details-leaked" value="/Node/d/4947" />
<add key="/4937/samsung-ativ-q-not-launching-this-year" value="/Node/d/4948" />
<add key="/4938/amazon-smartphone-3d-screen" value="/Node/d/4949" />
<add key="/4939/Newkia-a-Nokia-on-Android" value="/Node/d/4950" />
<add key="/4940/Nexus-5-first-proper-leaks-based-render-looks-exciting" value="/Node/d/4951" />
<add key="/4941/survey-iphone-5s-5c-upgrade" value="/Node/d/4952" />
<add key="/4942/ipad-ipad-mini-leak-alleged-tablet-shell" value="/Node/d/4953" />
<add key="/4943/redesigned-google-logo-found-in-chrome-for-android-beta" value="/Node/d/4954" />
<add key="/4944/Amazon-says-no-smartphone-this-year-no-free-phone-ever" value="/Node/d/4955" />
</rewriteMap>
</rewriteMaps>

我的web.config文件

my web.config file

<rewrite>
      <rewriteMaps configSource="rewriteMaps.config" />
      <rules>
        <rule name="Redirect old website urls">
          <match url=".*" />
          <conditions>
            <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}" appendQueryString="false" />
        </rule>
      </rules>
    </rewrite>

文件大小变为2 mb且超过12000 url,我问是否有重定向条件匹配这种情况!

the file size became 2 mb with more than 12000 url, i asking if there are a redirect condition match this case !

推荐答案

您需要使用此规则,而不是重定向旧网站网址,如果所有旧网址都是从4位数字

You need to use this rule, instead "Redirect old website urls", if all your old urls starts from number with 4 digits

<rule name="test" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{REQUEST_URI}" pattern="^/([0-9]{1,5})/.+" />
                </conditions>
                <action type="Redirect" url="/Node/d/{C:1}" />
            </rule>

这篇关于web.config old url to new url redirects的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆