Apache 有条件地重写url并使所有内容都小写

Apache 有条件地重写url并使所有内容都小写,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,所以,我有这样的URL:https://foobar.com/blog?category=Foo+条形码,其中实际get参数值可能包含或不包含加号(+) 我要做的是,在所有情况下,首先将参数值设置为小写,然后,如果参数值包含加号(+),则将其替换为连字符 最后,我试图得到https://foobar.com/blog?category=Foo+条码重写为https://foobar.com/category/foo-bar 到目前为止,我得到的是: Options +FollowSymLinks

所以,我有这样的URL:
https://foobar.com/blog?category=Foo+条形码,其中实际get参数值可能包含或不包含加号(+)

我要做的是,在所有情况下,首先将参数值设置为小写,然后,如果参数值包含加号(+),则将其替换为连字符

最后,我试图得到
https://foobar.com/blog?category=Foo+条码
重写为
https://foobar.com/category/foo-bar

到目前为止,我得到的是:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} ^/blog
RewriteCond %{QUERY_STRING} category=([^/]+)+([^/]+)$
RewriteRule (.*) /category/%1-%2? [R=301,L]
现在,这有点接近了,但它实际上重写了
https://foobar.com/blog?category=Foo+条码
https://foobar.com/category/Foo+Ba-r


任何帮助都将不胜感激。

请在htaccess文件的最后或
部分添加
RewriteMap lc int:tolower
。那你能试试下面的吗

RewriteEngine On
RewriteCond https on
RewriteCond %{REQUEST_URI} ^/blog$ [NC]
RewriteCond %{QUERY_STRING} ^([^=]*)=([^+]*)\+(.*)$ 
RewriteRule ^(.*)$ /%1/${lc:%2}-${lc:%3}   [QSD,R=301,L]
使用
curl
命令进行测试(使用http,但上面的规则负责
https
部分):


小写字母请参见对其进行了微调:
RewriteCond%{QUERY\u STRING}category=([^+]*)\+(.*+)$
@Milos,对不起,没有看到,如果这对您有帮助,请您现在检查一下好吗?
*+
与这里的
*
相同
curl -IL "http://localhost:80/blog?category=Foo+Bar"
HTTP/1.1 301 Moved Permanently
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.4.11
Location: http://localhost/category/foo-bar