I am having an issue trying to remove trailing slashes from the end of a query string in apache.
I have the following rewrite rules in place right now to make the URL and Query String all lowercase:
RewriteEngine On
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].* [OR]
RewriteCond %{QUERY_STRING} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}}?${lc:%{QUERY_STRING}} [L,R=301]
I have tried to add:
RewriteCond %{QUERY_STRING} (.+)/$
RewriteRule ^ %1 [R=301,L]
But it breaks the website. I have been searching for a way to do this but haven't come up with any solutions yet. I tried the answers from this post but they didn't work.
The reason I need to do this is because our application firewall looks for "ID" in the url and if there is any non alphanumeric character that comes after then it blocks the request. The firewall is implemented after the Apache request hits the server.
Hoping someone with more experience with Apache Rewrite rules can help me out. Thanks in advance.