Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6533649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:09:12+00:00 2026-05-25T10:09:12+00:00

I have written an external redirect file for use in a site. The redirect

  • 0

I have written an external redirect file for use in a site. The redirect works perfectly, but when I add a 404 rule, the redirect breaks. At that point, 404 works, but the redirect does not. I’ve also tried keeping the redirect rules inside of the web.config file (instead of as a separate file), but this does not work either.

Can anyone figure out how I can get my redirects and 404 rules working in tandem?

Below is the code for the redirect in the web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rewriteMaps configSource="rewritemaps.config" />
            <rules>
                <rule name="Redirect rule1 for Redirects">
                    <match url=".*" />
                    <conditions>
                       <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" url="{C:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

The external file referenced above looks like this:

<rewriteMaps>  
    <rewriteMap name="Redirects">  
        <add key="/old_page.html" value="/new_page.html" />  
    </rewriteMap>  
</rewriteMaps>

At this point everything works great. However, as soon as I add the following, the 404 works great, but the redirect does not work.

<httpErrors>
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="/page-not-found.html" responseMode="ExecuteURL" />
</httpErrors>

The total code that does not work is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rewriteMaps configSource="rewritemaps.config" />
            <rules>
                <rule name="Redirect rule1 for Redirects">
                    <match url=".*" />
                    <conditions>
                       <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" url="{C:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
        <httpErrors>
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/page-not-found.html" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:09:13+00:00Added an answer on May 25, 2026 at 10:09 am

    Your config is fine — no issues here.

    Try recycling app pool .. or restart IIS service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Service written in C# that handles all of our external
I have this servlet program and an external .jar file (written by someone else)
I have written this code in JavaScript and works perfectly fine when I include
I have written an xslt that reads some xml file names and does some
I have defined a GWT module that includes an external javascript file using tag.
I have written the following code to write to a file on external storage:
I have written an external script that needs to run after DOM is ready
I have written a Java code which imports an external jar file. How can
I have written a JavaScript script and saved it as an external file, and
I have written a script that is working perfectly except that I wish to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.