Remove trailing slashes from Query String Apache

Yamaha32088

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.

anubhava

To remove trailing slash from query string you can use this rule:

RewriteCond %{QUERY_STRING} ^(.+)/$
RewriteRule ^ %{REQUEST_URI}?%1 [R=301,L,NE]

Make sure this is first rule in your .htaccess below RewriteEngine On line.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

HAProxy remove trailing slashes

From Dev

remove slashes from the string in php

From Dev

How to remove a trailing question mark (empty query string) from the URL?

From Dev

Remove duplicate slashes and trailing slash

From Dev

Remove trailing slashes at the end of url

From Dev

Remove trailing '/' from rails string

From Dev

Remove Dynamic Query string from Apache

From Dev

Remove trailing slash and create query string with .htaccess

From Dev

Remove trailing slash and create query string with .htaccess

From Dev

Remove trailing slashes on multiple arguments in bash

From Dev

Remove trailing numbers from string js regexp

From Dev

Remove leading and trailing zeros from a string

From Dev

Remove trailing substring from String in Java

From Dev

How to remove a trailing comma from a string (Java)

From Dev

Remove trailing punctuation from concatenated string

From Dev

Remove leading and trailing zeros from a string

From Dev

Remove beginning or trailing comma from delimited string

From Dev

remove leading and trailing break tags from string

From Dev

Remove backwards slashes in string

From Dev

Slashes in a query string parameter?

From Dev

Slashes in a query string parameter?

From Dev

Remove "?" from the query string

From Dev

Mod rewrite remove query string after trailing slash

From Dev

How to remove all single slashes from a string while leaving double slashes intact

From Dev

Remove trailing string

From Dev

regex nginx remove trailing slashes not apply to 2 folders?

From Dev

Remove leading and trailing quotes from string if both are present

From Dev

iOS - remove trailing zeros from float WITHOUT converting to String?

From Dev

Javascript remove leading and trailing spaces from multiline string

Related Related

  1. 1

    HAProxy remove trailing slashes

  2. 2

    remove slashes from the string in php

  3. 3

    How to remove a trailing question mark (empty query string) from the URL?

  4. 4

    Remove duplicate slashes and trailing slash

  5. 5

    Remove trailing slashes at the end of url

  6. 6

    Remove trailing '/' from rails string

  7. 7

    Remove Dynamic Query string from Apache

  8. 8

    Remove trailing slash and create query string with .htaccess

  9. 9

    Remove trailing slash and create query string with .htaccess

  10. 10

    Remove trailing slashes on multiple arguments in bash

  11. 11

    Remove trailing numbers from string js regexp

  12. 12

    Remove leading and trailing zeros from a string

  13. 13

    Remove trailing substring from String in Java

  14. 14

    How to remove a trailing comma from a string (Java)

  15. 15

    Remove trailing punctuation from concatenated string

  16. 16

    Remove leading and trailing zeros from a string

  17. 17

    Remove beginning or trailing comma from delimited string

  18. 18

    remove leading and trailing break tags from string

  19. 19

    Remove backwards slashes in string

  20. 20

    Slashes in a query string parameter?

  21. 21

    Slashes in a query string parameter?

  22. 22

    Remove "?" from the query string

  23. 23

    Mod rewrite remove query string after trailing slash

  24. 24

    How to remove all single slashes from a string while leaving double slashes intact

  25. 25

    Remove trailing string

  26. 26

    regex nginx remove trailing slashes not apply to 2 folders?

  27. 27

    Remove leading and trailing quotes from string if both are present

  28. 28

    iOS - remove trailing zeros from float WITHOUT converting to String?

  29. 29

    Javascript remove leading and trailing spaces from multiline string

HotTag

Archive