开发者

IIS7 and 301 permanent redirects using the location tag in web.config

开发者 https://www.devze.com 2022-12-25 07:03 出处:网络
I need to setup some 301 permanent redirects in the web.config of an ASP.NET MVC application running under IIS.

I need to setup some 301 permanent redirects in the web.config of an ASP.NET MVC application running under IIS.

The easiest way is to add a tag similar to the one below to the web.config file:

 <location path="TheMenu.aspx">
        <system.webServer>
            <httpRedirect enabled="true" destination="menus/" httpResponseStatus="Permanent" />
        </system.webServer>
    </location>

When I go to the site at http://domain.com/TheMenu.aspx it redirects me to http://domain.com/menusxd instead of http://domain.com/menus.

What would be 开发者_开发知识库causing this?


Sorry I can't help you with <httpRedirect> but have you tried / can you use the IIS7 URL Rewrite module?

Your rule would look something like:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="TheMenu" patternSyntax="Wildcard" stopProcessing="true">
                <match url="TheMenu.aspx" />
                <action type="Redirect" url="menus/" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

HTHs,
Charles

0

精彩评论

暂无评论...
验证码 换一张
取 消