Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

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

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 "default" methods can be ignored (by default index()), so this results in URLs like /controller//param1/param2/param.... For example, a URL of: /view//panel-glide/3 will call index('panel-glide', 3) in the view controller.

This works fine and dandy, but I'm concerned that search engines or some older browsers might freak out when they see the double slashes, as I don't think I've actually seem them ever be used before.

Is anyone aware of any issues I might come across by using this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...