Mod_rewrite - 如何将旧 URL 301 重定向到新 URL
我需要获取网站的一些旧 URL 并执行 301 重定向到新 URL,因为它们已经编入索引,并且我们不想在更改后失去相关性。 旧的 URL 实际上非常丑陋,并且出于某种原因,我尝试重写它的所有方法都不起作用。 基本上
http://www.mywebsite.com/ExibeCurso.asp?Comando=TreinamentoGeral&codCurso=136&Titulo=Como%20Estruturar%20um%20Sistema%20Gerencial%20de%20Controles%20Organizacionais,13
,我需要将其翻译为:
http://www.mywebsite.com/curso/136
从旧 URL,我需要检查用户是否键入了“ExibeCurso.asp”; 然后我知道我必须把他送到这里:/curso。 我还必须获取查询字符串参数“codCurso”(136)中的整数。 我必须为此使用什么正则表达式? 我使用的是ISAPI_Rewrite 3,它基本上在IIS上实现了htaccess,所以语法上应该没有区别。 谢谢。
I need to grab some of my website's old URLs and do a 301 redirect to the new ones, since they are already indexed and we don't want to loose relevance after the change. The old URL is in fact very ugly and for some reason everything I try to do to rewrite it does not work. Here it is:
http://www.mywebsite.com/ExibeCurso.asp?Comando=TreinamentoGeral&codCurso=136&Titulo=Como%20Estruturar%20um%20Sistema%20Gerencial%20de%20Controles%20Organizacionais,13
Basically, I need to translate it into something like:
http://www.mywebsite.com/curso/136
From the old URL I need to check if the user typed "ExibeCurso.asp"; then I know I must send him here: /curso. I must also grab the integer that was in the querystring parameter "codCurso" (136). What is the regular expression I must use for this. I am using ISAPI_Rewrite 3, which basically implements htaccess on IIS, so there should be no difference in terms of syntax. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这个规则:
但我不确定 ISAPI Rewrite 是否要求模式以斜杠开头。
Try this rule:
But I’m not sure whether ISAPI Rewrite requires the pattern to begin with a slash.
在我的脑海中,类似这样的东西应该可以工作:
这至少会将流量发送到 /curso/ 并附加所有参数。 也许最好从那里开始处理。
Off the top of my head, something like this should work:
That would at least send the traffic to /curso/ with all parameters attached. Maybe it's best to process it from there.