.htaccess 用于在访问 URL 时重定向特定索引文件


.htaccess to redirect specific index file when url is visited

我的产品网址如下所示:http://www.example.com/products/handbags/leather-handbag-model-ba123其中handbags是类别名称,并且正在动态更改。 leather-handbag-model-ba123是一个产品唯一的URL,并且也在动态变化。
.htaccess文件中,我有这个:

RewriteCond %{THE_REQUEST} /(products)/([^'s&]+)/([^'s&]+) [NC]
RewriteRule /%1/%2/index.php [L] 

它应该加载位于/products/handbags/index.php 中的 index.php 文件,但代码返回错误 404。
加载特定类别(示例中handbags)的索引.php文件的正确代码是什么?

使用:

RewriteCond %{REQUEST_URI} !index'.php$ [NC]
RewriteRule ^(products)/([^/]+)/.+/? /$1/$2/index.php [L]