Rewriting url conditionally and making everything lowercase

Please add RewriteMap lc int:tolower at last of your htaccess file or in your <VirtualHost> section. Could you please try following then.

RewriteEngine On
RewriteCond https on
RewriteCond %{REQUEST_URI} ^/blog$ [NC]
RewriteCond %{QUERY_STRING} ^([^=]*)=([^+]*)\+(.*)$ 
RewriteRule ^(.*)$ /%1/${lc:%2}-${lc:%3}   [QSD,R=301,L]

Testing with curl command(with http but rule above takes care of https part):

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

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top