Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "/./" mean in href link?

Tags:

html

url

path

php

href

Recently I'm reading some webpages and I found there are a lot of usages like: href="/./foo/bar.php"

Isn't this the same as href="/foo/bar.php"? Or is this there something I don't know about the differences between the two ways?

like image 990
ChandlerQ Avatar asked Feb 14 '23 18:02

ChandlerQ


1 Answers

The relative URL /./foo/bar.php is not the same as the relative URL /foo/bar.php. The former has /. at the beginning.

They have the same effect, though. When URLs are processed, relative URLs are resolved to absolute URLs, and in this process, if a relative URL starts with /./, it is replaced by /. Reference: STD 66, clause Remove Dot Segments. (Such a reference is turn resolved as relative to the server root, basically something like http://www.example.com/foo/bar.php.)

So these two relative URLs always resolve to the same absolute URL. There is in general no reason to use the longer URL, which looks more complicated and confusing.

Note that this has absolutely nothing to do with folders or files. It is simply string manipulation, based on the URL standard. Whether URLs get mapped to folders and files is at the discretion of a server and in principle invisible to the world outside it.

like image 151
Jukka K. Korpela Avatar answered Feb 17 '23 10:02

Jukka K. Korpela