2

I'm having troubles with the flag Next [N] in mod_rewrite

I wanna replace ALL slashes (/) in the url by an underscore. I've tried many regexps that work well for any other language, but to mod_rewrite doesn't. Like:

/ _ [N]

or

(.*)/(.*) $1_$2 [N]

But the mod_rewrite seems enter in an endless loop.

I want a routine that works for X number of slashes, not limited to 3 or 4 slashes, for example.

Thanks.

user464230
  • 876
  • 2
  • 11
  • 21

1 Answers1

0

The solution should be very similar to solution provided in mod_rewrite: replace underscores with dashes

You essentially need two rules total, the first being the one using the Next [N] flag but with the addition of a check to ensure there are always 2 slashes (which you are missing). Then you need a final rule to finish it off with the redirect and include the last [L] flag.

Hope that helps

Community
  • 1
  • 1
Anthony Hatzopoulos
  • 10,437
  • 2
  • 40
  • 57