开发者

mod_rewrite replace all slashes (/)

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 w开发者_开发技巧ork 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜