我注意到我的域名在Google Analytics上显示有很多访问量,但是这些访问链接到已经不存在的.asp页面。而我们已经把所有东西都迁移到了.NET平台上,因此我希望使用301重定向。
在花费了一些时间进行谷歌搜索之后,我已经能够将以下代码添加到我的web.config中。
<location path="products.asp">
<system.webServer>
<httpRedirect enabled="true" destination="https://www.hartnollguitars.co.uk/products.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
这样做可以将所有内容从products.asp
移动到pproducts.aspx
,但它并没有保留查询字符串,这对于理解非常关键,比如products.aspx?id=789