简体   繁体   中英

web.config: URL rewrite to remove directory

So currently I've got the URL websitename.com/posts/post

and I would like to change it to websitename.com/post

I've been trying now for 3 days with no luck. Seen loads of stuff for .htaccess but not much for web.config

Apologies in advance as I'm sure I'm asking a really dumb question,

Thank you!

Maybe this is what you want. Put it in the root directory of your website. You could also change Rewrite to Redirect there.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="posts" patternSyntax="ExactMatch">
                    <match url="/posts/post" />
                    <action type="Rewrite" url="/post" />
                </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