Score:1

How to make multiple changes to REQUEST_URI at once?

cn flag

I'm dealing with requests from a proprietary client, that sometimes uses back- rather than forward-slashes: GET /path\to\the\file.txt, and I'd like to straighten them all out.

mod_rewrite can replace one at a time:

RewriteRule ^(.*)\\+(.*) $1/$2 [QSA]

but how would I replace all such occurrences at once, like sed's /g modifier?

anx avatar
fr flag
anx
Beware of order/interaction with existing rules, especially B/BNP/BCTLS/BNE.. depending on the client you are working with, at least one explicit redirect may be preferable to internal rewrites.
cn flag
Considering this vendor's software quality, I doubt, this client can handle redirects _at all_...
Score:1
jp flag

Should be possible with something like:

RewriteRule ^/([^\\]*)\\([^\\]*\\.*) /$1/$2 [N]
RewriteRule ^/([^\\]*)\\([^\\]*)$ /$1/$2

https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_n

The [N] flag causes the ruleset to start over again from the top, using the result of the ruleset so far as a starting point. Use with extreme caution, as it may result in loop.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.