Jam*_*oll 5 asp.net redirect web-config url-rewriting
我正在考虑使用301重定向,注意到我的域上的一些点击在Google Analytics上发送到.asp页面,这些页面已不再存在,已将所有内容移至.NET设置.
花了一些时间谷歌搜索,我已经能够将以下代码添加到我的web.config.
<location path="products.asp">
<system.webServer>
<httpRedirect enabled="true" destination="https://www.hartnollguitars.co.uk/products.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
Run Code Online (Sandbox Code Playgroud)
这很好并且可以移动所有内容products.asp,pproducts.aspx但它不会保留查询字符串,这对任何意义都是必不可少的,即products.aspx?id=789
您必须添加 $Q到目标URL以保留查询字符串.所以在你的情况下它应该是这样的:
<location path="products.asp">
<system.webServer>
<httpRedirect enabled="true" destination="https://www.hartnollguitars.co.uk/products.aspx$Q" httpResponseStatus="Permanent" />
</system.webServer>
</location>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6388 次 |
| 最近记录: |