[BNM] Rewriting b*tard back-to-front slashes
Jay Caines-Gooby
jay at gooby.org
Mon Nov 27 16:01:57 GMT 2006
On 11/27/06, Dominic Mitchell <dom at happygiraffe.net> wrote:
> On Mon, Nov 27, 2006 at 02:01:11PM +0000, Jay Caines-Gooby wrote:
> > Can anyone help me with this mod_rewrite conundrum?
> >
> > I've got requests coming to my webserver of the form
> >
> > \some\request\with\backslashes\not\forward\slashes
> >
> > I need to rewrite this to:
> >
> > /some/url/with/backslashes/not/forward/slashes
> >
> > and to make things really awkward, there can be any number of
> > backslashes that need converting.
> >
> > In a normal regex I'd just do $url ~= s/\\/\// but how do I do this as
> > a mod_rewrite rule?
>
> Assuming Apache 1.3, (although 2.0 and later shouldn't be different),
> I'd guess something like this.
>
> RewriteEngine on
> RewriteRule \\ / [N]
>
> The N flag should restart rewriting each time it matches, so it should
> replace each backslash with a slash until there are none left.
>
> Caveat: this is completely untested.
Thanks Dom,
Didn't work but got me part way there.
RewriteEngine On
RewriteRule (.*)\\(.*) $1/$2 [N,NE]
Works on Apache 1.3 (not sure that I need the NE, but I didn't want
the slashes getting URL escaped).
Doesn't work on Apache2 though :(
I get:
RewriteRule: cannot compile regular expression '(.*)\\(.*)'
in the error log. Bah.
--
Jay Caines-Gooby
jay at gooby.org
+44 (0)7956 182625
skype:jaygooby
http://snipperoo.com
http://blog.snipperoo.com
More information about the BNMList mailing list
BNMList is hosted by Screenlists, a Screen-Play.net service