简体   繁体   中英

IIS Url Rewrite Rule

I am new to Url rewrite rules so any help would be gratefully appreciated.

Looking to create a IIS Url rewrite that will handle any of the following

http://localhost/homepage/contact-us.aspx -> http://localhost/contact-us.aspx
http://localhost/homepage/about-us.aspx -> http://localhost/about-us.aspx

Any ideas?

I haven't tested this but I think you would have something like this in your web.config file.

You can edit the web.config file and then go into IIS and the rule should show up if you want to test it.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="rewriterule1" enabled="true" stopProcessing="false">
                    <match url="homepage/(.*)" />
                    <action type="Rewrite" url="http://localhost/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

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