RegEx帮助URL重定向?

时间:2012-03-15 12:43:31

标签: regex url web url-rewriting

我需要帮助创建正则表达式,以便将旧网址重定向到新网址。我刚刚切换平台(到WordPress btw :)并且链接的构造方式不同。谁能看到我可以使用的正则表达式?

Events -    
OLD: /cms/events/view/12-03-19/human_rights_framework_for_activists.aspx
NEW: /events/view/human-rights-framework-for-activists/

OLD: /cms/events/view/12-03-26/media_skills_for_activists.aspx  
NEW: /events/view/media-skills-for-activists/

OLD: /cms/events/view/12-03-20/environmental_justice_toronto.aspx
NEW: /events/view/environmental-justice-toronto/

OLD: /cms/events/view/12-04-11/report_back_from_the_un_session_of_the_56th_commission_on_the_status_of_women.aspx
NEW: /events/view/report-back-from-the-un-session-of-the-56th-commission-on-the-status-of-women/

OLD: /cms/events/view/12-03-16/create_your_annual_fundraising_plan_from_scratch.aspx
NEW: /events/view/create-your-annual-fundraising-plan-from-scratch-2-2012-03-16/

News -
OLD: /cms/news/view/11-10-11/culture_of_peace_-press_release.aspx
NEW: /culture-of-peace-press-release/

Catch all -
OLD: /cms/events/view/*
NEW: /events

OLD: /cms/*
NEW: /

1 个答案:

答案 0 :(得分:0)

我会说只使用.htaccess文件

RewriteEngine on
RewriteBase /
RewriteRule old_link new_link
RewriteRule old_link new_link
RewriteRule old_link new_link