如何在apache中重定向文件夹而不影响其文件?

如何在apache中重定向文件夹而不影响其文件?,apache,.htaccess,redirect,http-status-code-301,Apache,.htaccess,Redirect,Http Status Code 301,我的.htaccess文件中有以下重写规则: Redirect 301 /products http://example.com/products.html 这很好,但是会影响文件夹中文件的URL,因此: http://example.com/products/item.html 被重定向到: http://example.com/products.html/item.html 是否有任何方法可以使我只将重定向指向父文件夹,而不指向其中的文件 是否有任何方法可以使我只将重定向指向父文件夹,

我的
.htaccess
文件中有以下重写规则:

Redirect 301 /products http://example.com/products.html
这很好,但是会影响文件夹中文件的URL,因此:

http://example.com/products/item.html
被重定向到:

http://example.com/products.html/item.html
是否有任何方法可以使我只将重定向指向父文件夹,而不指向其中的文件

是否有任何方法可以使我只将重定向指向父文件夹,而不指向其中的文件

是使用
RedirectMatch
使用正则表达式精确定位:

RedirectMatch 301 ^/products/?$ http://example.com/products.html

Regex
^/products/?$
将匹配
/product
/product/
但不匹配
/product/file

谢谢我一直在玩重定向匹配,但我无法正确使用Regex