如何使用 htaccess 重定向带有通配符的路径

编程入门 行业动态 更新时间:2024-10-25 08:28:45
本文介绍了如何使用 htaccess 重定向带有通配符的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近升级了一个网站.旧站点的日历创建了数百个页面,在新站点上,它已被事件页面取代,并且这些日历 URL 不再存在.几个月来,我一直让搜索引擎猛烈抨击这些不再存在的页面.

I have a site I recently upgraded. The old site had a calendar that created hundreds of pages, on the new site this has been replaced by an events page and those calendar URL's no longer exist. For months now I have been getting search engines pounding no longer existent pages like these ones.

例如:

page not found calendar-for-groups/2012-09-15/1093 page not found calendar-for-groups/2011-W09/77 page not found calendar-for-groups/2011-W27/77 page not found calendar-for-groups/2012-06-29/1093

如何使用 htaccess 将任何 www.mywebsite/calendar-for-groups/* 请求重定向到 www.mywebsite/events?>

How can I use htaccess to redirect any www.mywebsite/calendar-for-groups/* request to www.mywebsite/events?

推荐答案

您可以使用 mod_alias 的 RedirectMatch 指令:

You could use the RedirectMatch directive of mod_alias:

RedirectMatch 301 ^/calendar-for-groups/.*$ www.mywebsite/events

或者使用mod_rewrite:

RewriteRule ^calendar-for-groups/ www.mywebsite/events [R=301,L]

更多推荐

如何使用 htaccess 重定向带有通配符的路径

本文发布于:2023-10-31 16:37:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通配符   如何使用   路径   重定向   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!