注:此代码只适用于IIS服务器,如需要将123.asp重定向到123.html,请使用以下代码。

修改说明: 在web.config文件中添加301重定向规则,将123.asp重定向到123.html

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect" stopProcessing="true">
                    <match url="^123.asp" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Redirect" url="123.html" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

解释:

  • match url="^123.asp":匹配所有访问123.asp的请求。
  • action type="Redirect" url="123.html" redirectType="Permanent":将匹配的请求永久重定向到123.html

通过以上步骤和代码修改,您可以实现站内页面的301永久重定向,有助于SEO优化和用户体验。