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.
我有一个我最近升级的网站。旧网站有一个创建了数百个页面的日历,在新网站上,它已被事件页面取代,并且这些日历URL不再存在。几个月来,我一直在让搜索引擎不再像这些那样存在。
For example:
例如:
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
How can I use htaccess to redirect any www.mywebsite.com/calendar-for-groups/*
request to www.mywebsite.com/events
?
如何使用htaccess将任何www.mywebsite.com/calendar-for-groups/*请求重定向到www.mywebsite.com/events?
2 个解决方案
#1
38
You could use the RedirectMatch
directive of mod_alias
:
您可以使用mod_alias的RedirectMatch指令:
RedirectMatch 301 ^/calendar-for-groups/.*$ http://www.mywebsite.com/events
Or with mod_rewrite
:
或者使用mod_rewrite:
RewriteRule ^calendar-for-groups/ http://www.mywebsite.com/events [R=301,L]
#2
9
You can do with a few rewrite rules:
您可以使用一些重写规则:
RewriteEngine on
RewriteRule ^calendar-for-groups/(.*) /events [R=301,L]
#1
38
You could use the RedirectMatch
directive of mod_alias
:
您可以使用mod_alias的RedirectMatch指令:
RedirectMatch 301 ^/calendar-for-groups/.*$ http://www.mywebsite.com/events
Or with mod_rewrite
:
或者使用mod_rewrite:
RewriteRule ^calendar-for-groups/ http://www.mywebsite.com/events [R=301,L]
#2
9
You can do with a few rewrite rules:
您可以使用一些重写规则:
RewriteEngine on
RewriteRule ^calendar-for-groups/(.*) /events [R=301,L]