我的产品网址如下所示: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]