简体   繁体   中英

IIS Url Rewrite Module redirect url that does not exit to one that exists

Is there a way to redirect to a URL when a user inputs a URL in the browser that does not have an actual address but is under said domain, using the URLRewrite Module in IIS 7.5 or 8.5?

example: https://examplesite.com/test

redirected to: https://examplesite.com/site/home.aspx

   <rewrite>
        <rules>
            <rule name="redirectURL" enabled="true" stopProcessing="true">
                <match url="^.*(/test)$" />
                <action type="Redirect" url="https://examplesite.com/site/home.aspx" appendQueryString="false" />
            </rule>
        </rules>
    </rewrite>

Every entry I have tried using this module does not seem to work for this scenario.

I don't know if you can do it under IIS Rewrite rules but you can define custom error handling

<customErrors defaultRedirect="ErrorPage.aspx" mode="On">       
    <error statusCode="404" redirect="https://examplesite.com/site/home.aspx" />
</customErrors>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM