如何使用htaccess重定向带有通配符的路径 [英] How can I use htaccess to redirect paths with a wildcard character

查看:131
本文介绍了如何使用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.com/calendar-for-groups/*请求重定向到www.mywebsite.com/events?

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

推荐答案

您可以使用mod_aliasRedirectMatch指令:

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

或使用mod_rewrite:

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

这篇关于如何使用htaccess重定向带有通配符的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆