Error using rewritemaps attributeRSS

2 replies

Last post Apr 30, 2020 09:52 AM by samwu

  • Error using rewritemaps attribute

    Apr 29, 2020 03:48 PM|alvargamdc|LINK

    I Created a web.config file to redirect old site pages to new site pages within the site but there are two issues:

    1. 1. The current http to https rule stops working after adding the rewritemaps option
    2. 2. From the list of links on the rewritemaps list only the first two redirects work, the other two does not work.

    I use the IIS 10 rewrite package  to create the web.config file.


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="SecureIndexPage" patternSyntax="ECMAScript" stopProcessing="true">
                        <match url="^$" />
                        <action type="Redirect" url="https://www.publicdefender.com/home.asp" appendQueryString="false" redirectType="Found" />
                    </rule>
                    <rule name="All requests secure redirect" stopProcessing="true">
                        <match url="^.+$" />
                        <conditions>
                            <add input="{HTTPS}" pattern="OFF" />
                        </conditions>
                        <action type="Redirect" url="https://www.publicdefender.com/{R:0}" logRewrittenUrl="true" redirectType="Permanent" />
                    </rule>
                    <rule name="Redirect rule1 for oldsite">
                        <match url=".*" />
                        <conditions>
                            <add input="{oldsite:{REQUEST_URI}}" pattern="(.+)" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                </rules>
                <rewriteMaps>
                    <rewriteMap name="oldsite">
                        <add key="/volunteer.asp" value="/public-defender/volunteer.asp" />
                        <add key="/contact.asp" value="/public-defender/contact.asp" />
                        <add key="/employees.asp" value="/public-defender/employees.asp" />
                        <add key="/donate.asp" value="/public-defender/donate.asp" />
                        <add key="/work.asp" value="/public-defender/work.asp" />
                        <add key="/location.asp" value="/public-defender/location.asp" />
                        <add key="/maps.asp" value="/public-defender/maps.asp" />
                        <add key="/clients.asp" value="/public-defender/clients.asp" />
                    </rewriteMap>
                </rewriteMaps>
            </rewrite>
        </system.webServer>
    </configuration>

  • Re: Error using rewritemaps attribute

    Apr 29, 2020 08:10 PM|lextm|LINK

    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Error using rewritemaps attribute

    Apr 30, 2020 09:52 AM|samwu|LINK

    Hi alvargamdc, 

    The rules work like a charm so could you help clear whether binding https://www.publicdefender.com and http://www.publicdefender.com are under the same site?

    If so, please try to clean browser cache.  

    If they are under different sites, please swap the order of rule #2 and #3. 

    Best regards,

    Sam