Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm still very new to using URL rewrites and redirects and I'm having some problems on something I thought was quite simple...

I've just rebuilt a website and want to redirect the old URLs to the new ones.

For example:


Should now be:


Unfortunately, everything I've tried is giving me errors or simply does nothing.

Here is one rule I tried:

<rule name="redirectoldabout" enabled="true" stopProcessing="true">
    <match url="( .*)" negate="true" />
    <add input="{HTTP_HOST}" pattern="^mydomain\.com/about\.asp\?lang=1$" />
    <action type="Redirect" url="http://www.mydomain.com/content.asp?id=100230&title=about&langid=1" redirectType="Permanent" />

but I get an error back:

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

Any suggestions as to what I'm doing wrong?

share|improve this question
up vote 0 down vote accepted

Forget the 301 in your web.config for now.

Enter this in your global.asax file near the bottom:

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    If (HttpContext.Current.Request.Url.ToString().ToLower().Contains(
"http://www.mydomain.com/about.asp?lang=1")) Then

        HttpContext.Current.Response.Status =
            "301 Moved Permanently"

    End If
        End Sub

Save and upload. This will take care of the issue.

If you're more comfortable editing your web.config, see this link on SE for more information.

share|improve this answer
thanks very much for your reply... i would rather use the web.config as i already have some redirects there (redirecting from mydomain.com to www.mydomain.com for example)... i checked the link you provided to stackoverflow and found something there which helped... my working rule : '<rule name="About Us redirect from old site" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" pattern="about.asp" /> </conditions> <action type="Redirect" redirectType="Permanent" url="content.asp?id=100230" /> </rule>' – Dog Nov 13 '12 at 15:05
Glad to hear you worked things out! – Jason Weber Nov 13 '12 at 23:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.