Ahmad Alaa
Ahmad Alaa

Reputation: 817

web.config old url to new url redirects

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>

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>

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

Upvotes: 0

Views: 1320

Answers (1)

Victor Leontyev
Victor Leontyev

Reputation: 8736

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>

Upvotes: 1

Related Questions