Are there any downsides to using double-slashes in URLs?

前端 未结 2 1011
情书的邮戳
情书的邮戳 2020-12-16 15:08

I\'ve written my own MVC framework in PHP, which uses urls in the format of:

/controller/method/param1/param2/param...

I\'ve made it so that \"d

2条回答
  •  借酒劲吻你
    2020-12-16 16:06

    There is an existing answer on WebMasters that discusses the dangers of having two slashes. It discusses Apache a lot, but the ideas should be applicable generally.

    In essence, I don't think it is recommended. /foo/bar and /foo//bar really should be two completely different paths. Each slash is significant, and attempts at circumventing that standardization are bound to come back to bite you.

    As is mentioned in the answer, there's also a very real danger of relative paths failing. Some browsers will correctly figure that a relative path ../../fizz from /foo/bar//baz is /foo/bar/fizz, while others will treat the double slash as a single one, and opt for /foo/fizz.

    Plus, I think it looks funny.

提交回复
热议问题