htaccess 301 重定向查找和替换
我有一个网站,涉及印度各个城市。代码从外部源创建链接,可能将一个城市命名为加尔各答、加尔各答、加尔各答等。
我需要一个 htaccess 301 重定向规则,考虑到所有拼写错误,该规则将重定向以下已知的良好拼写(加尔各答):
Calcutta-to -Delhi.html 到 Kolkata-to-Delhi.html
以及
Calcuta-Airport.html 到 Kolkata-Airport.html
谢谢。
I have a website which refers to to various Indian cities. Code makes links from an external source, which may name a city as Calcutta, calcuta, Kolkata, etc.
I need a htaccess 301 redirect rule which, given all the misspellings would redirect the following the known good spelling (Kolkata):
Calcutta-to-Delhi.html to Kolkata-to-Delhi.html
and also
Calcuta-Airport.html to Kolkata-Airport.html
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你所要求的并不简单,需要你拥有一台功能强大的计算机,但结果却是令人惊叹的。
我建议这样做:
/
匹配,即http://mysite.com/(expr1)-to-(expr2)/
/(expr1)-to-(expr2)/
匹配,则执行 SOUNDEX 使用 MySQL 进行搜索(在您的Php
文件中)。请参阅此处的查询示例。Kolkata-to-Delhi.html
?如果是这样,请单击链接”。这是一项艰苦的工作,但既有趣又能展示你的技能。很少有网站这样做(我实际上只知道谷歌)。
What you're asking for is not simple and need you to have a powerful computer, but the results are simply amazing.
Here's what I'd suggest to do:
/
i.e.http://mysite.com/(expr1)-to-(expr2)/
/(expr1)-to-(expr2)/
then do a SOUNDEX search with MySQL (in yourPhp
file). See query sample here.Kolkata-to-Delhi.html
? if so, click on the link".This a hard work, but it's both interesting and shows your skill. Very few websites do this (I just know google actually).
也许你可以尝试这样的事情:
注意“[nocase]”,它忽略大小写。这只会从“加尔各答”重定向到“加尔各答”,而不是从“加尔各答”或“加尔各答”重定向(请注意加尔各答中缺少“t”,加尔各答中缺少大写“K”)。
您将需要按照与上面相同的代码模式添加另外两个规则。
Maybe you can try something like this:
Notice the "[nocase]" which ignores case. This will only redirect from "calcutta" to "kolkata" and not from "calcuta" or "Kolkata" (notice the missing 't' in calcuta and uppercase 'K' in Kolkata).
You will need to add two more rules following the same pattern of code as above.