Redirect 301使用web.config重定向或重写
我需要配置重写以将两个经典asp动态文件重定向到两个不同的asp文件: example.com/file.asp?id=100 => example.com/file.asp?id=200 example.com/file.asp?id=100&bc=no => example.com/file.asp?id=200&bc=no example.com/file.asp?id=100=>example.com/file.asp?id=200 example.com/file.asp?id=100&bc=no=>example.com/file.asp?id=200&bc=no 我不是专家,我一直在寻找答案,但所有的建议都指向Redirect 301使用web.config重定向或重写,redirect,url-rewriting,asp-classic,web-config,Redirect,Url Rewriting,Asp Classic,Web Config,我需要配置重写以将两个经典asp动态文件重定向到两个不同的asp文件: example.com/file.asp?id=100 => example.com/file.asp?id=200 example.com/file.asp?id=100&bc=no => example.com/file.asp?id=200&bc=no example.com/file.asp?id=100=>example.com/file.asp?id=200 example.com/file.as
.htaccess
,我的网站是在windows server上托管的
因此,我知道我必须配置我的web.config
来重写
有什么想法吗?根据您给出的示例,您看起来并没有重定向到其他文件,只是修改了querystring参数 如果您正在重定向到另一个文件(我们称之为file2.asp),请尝试
strQS = Request.QueryString
If strQS <> "" Then strQS = "?" & strQS
strURL = "file2.asp" & strQS
Response.Redirect strURL
Response.End
strQS=Request.QueryString
如果是strQS“”,则strQS=“?”&strQS
strURL=“file2.asp”和strQS
响应。重定向strURL
答复.完
在file.asp顶部的某个地方谢谢Stephen,但我需要重定向到“file.asp”,而不是另一个文件。旧产品id为100,该产品的新查询字符串为200。。。但是谷歌的搜索结果,论坛链接,都指向100,所以我需要告诉他们产品现在在哪里。明白了-我们在谈论多少产品?有没有一个公式可以表达产品id是如何变化的,还是随机的?嗨,Stephen。也许我们谈论的是3或4种产品。这是一个具体的问题,我想抓住这一刻,学习如何做(重定向或重写),以防将来遇到同样的问题。产品id是数据库中的一个条目,通常我不会因为seo而更改它们。谢谢你的兴趣!好的,我相信经典的asp response.redirect会发布一个302临时重定向,这对SEO不太友好。你会想要一个发出301的方法。重定向永久。由于这只是少数几个产品,可以在页面中处理,请尝试在页面顶部使用这种代码<代码>显然,您需要为每个产品id添加某种IF语句。