In a question regarding a jQuery Ajax problem, the asker was trying to use a . in the beginning of a relative URL. I advised him to remove it, but have no idea what a dot actually does there.
His relative URL looked like this:
./delete-misc/test-ajax-code.php
I tried looking in the RFCs, without success. I know what the dot does in command line (either Linux or Win), it represents the current directory.
I’d like to know: how does this work on the Internet in a URL? Does it have any best-practice uses? Detailed explanations are most welcome.
The path segment
.is typically used at the begin of relative path references and are removed during the reference resolution, i.e. the process of resolving a relative URI reference to an absolute URI:There is Remove Dot Segments algorithms that describes how these dot segments are to be interpreted in a certain base path context.
In your case both
./delete-misc/test-ajax-code.phpanddelete-misc/test-ajax-code.phpare equivalent. But there are cases where a relative path can be misinterpreted as an absolute URI, e.g. having a:in the first path segment likesearch:foothat is different to./search:fooas the former is an absolute URI while the latter is a relative URI path.