Wrong slashes in the url?

I have noticed that https://stackoverflow.com/a/3776185/ is a valid URL. However, https://www.google.com//////////analytics/settings - no. Are there differences in web server technologies that explain this? Should I interpret the URL with unnecessary slashes correctly or return an error?

+6
source share
4 answers

First of all, adding a slash changes the semantics of the URL path, just like any other character. Therefore, by definition, /foo/bar and /foo//bar not equivalent, since /foo/bar and /foo/bar/ not equivalent.

But since the URL path is mainly used for direct mapping to the file system, web servers often delete empty path segments (Apache does this), so that /foo//bar and /foo/bar treated equivalently. But this is not the expected behavior; rather, it was done to correct errors.

+4
source share

They are both valid URLs.
However, the Google server cannot handle the second.

There is no specific reason to process or reject URLs with duplicate slashes; you should spend more time on more important things.

+2
source share

What do you think is "correctly interpreted"? HTTP really defines how the material before the slash after interpreting the server name. The rest is entirely up to the web server. He analyzes what you give him after this moment (whatever you like) and presents you with any HTML code that seems to provide that text.

+1
source share

There is a difference in how each application handles requests. If you configured the application to replace subsequent slashes before sending the request, you should have no problems.

0
source share

All Articles