本文介绍了如何使用 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 重定向带有通配符的路径
发布评论