2

我想将多个 URL 重定向到同一页面。

我可以这样做:

Redirect /index.html http://example.com/newdirectory/
Redirect /index1.html http://example.com/newdirectory/
Redirect /index2.html http://example.com/newdirectory/
Redirect /index3.html http://example.com/newdirectory/
Redirect /index4.html http://example.com/newdirectory/
Redirect /index5.html http://example.com/newdirectory/

没有更好的方法来做到这一点吗?(更干净)

4

1 回答 1

2

是的,RedirectMatch您可以在模式中使用正则表达式:

RedirectMatch 302 ^/(index|index1|index2|index3|index4|index5)\.html$ http://example.com/newdirectory/

甚至更简洁:

RedirectMatch 302 ^/index[1-5]?\.html$ http://example.com/newdirectory/
于 2013-10-02T15:41:33.683 回答