301重定向第一个子文件夹

时间:2016-12-09 19:24:27

标签: .htaccess redirect

我有一个301重定向从一个页面到另一个页面

REDIRECT 301 /cloud-computing /it-infrastructure/cloud-computing

现在,当我使用此重定向时,云计算的子页面也会受到此301重定向的影响,但必须将其重定向到其他位置。我怎样才能重定向文件夹而不是子页面?

1 个答案:

答案 0 :(得分:1)

您应该使用RedirectMatch使用正则表达式进行精确匹配:

RedirectMatch 301 ^/cloud-computing/?$ /it-infrastructure/cloud-computing

在测试更改之前清除浏览器缓存。