htaccess 重写多个页面的查询字符串

htaccess rewrite for query string for multiple pages

我非常感谢有关 .htaccess 重写多个页面的查询字符串的帮助。

原页面是/products.php?q=anything&type=cat

而且我想知道如何将上面的 url 重写为 /category/anything/page。html

我试图从几个在线资源中找到解决方案,但似乎在我放置重写规则后,每次都 return 到 products.php。

谢谢

这是假设您始终将用户发送到 "page.html",并且唯一的变量是 "anything"。如果这是真的,这应该有效:

RewriteRule ^category/(anything)/page.html /products.php?q=&type=cat

它将使网络服务器将 /category/something/page.html 的查询发送到 /products.php?q=something&type=cat