使用多个 URL 的查询字符串重写规则

Rewrite rules with query-string for multiple URLs

我想重定向所有 URL 如下

http://domain.com/?s=25 ...> http://domain.com/s=25.html

对于每个 URL 我可以执行以下操作:

RewriteCond %{QUERY_STRING} (^|&)s\=25($|&)
RewriteRule ^$ /s=25.html?&%{QUERY_STRING}

我想重写“?”之后的所有内容

例如:

 /?s=25        ...> /s=25.html
 /?cat=2       ...> /cat=2.html
 /?page_id=25 ...> /page_id=25.html

如何使用一条规则对多个文件执行此操作?

如有任何帮助,我们将不胜感激!

这应该为您提供一条规则。试试这个,让我知道。

RewriteEngine on
RewriteCond %{QUERY_STRING} (?:^|&)(page_id|cat|s)=(.+)(?:$|&)
RewriteRule ^$ /%1=%2.html [L,QSA]