single dot prefix for hyperlinks

D

Dave

Hi,

Can anyone tell me the difference between the following where
"Test.asp" is found in the same folder as the target page calling the
hyperlink "Last Image"?

1. <a href="./Test.csp">Last Image</a>
2. <a href="Test.asp">Last Image</a>

Thanks in advance,
Dave
 
A

Andy Dingley

Dave said:
Can anyone tell me the difference between the following where
"Test.asp" is found in the same folder as the target page calling the
hyperlink "Last Image"?

1. <a href="./Test.csp">Last Image</a>
2. <a href="Test.asp">Last Image</a>

One is "csp"

Otherwise the resolution of the URLs ought to point to the same
directory. As to the actuality for your real server, then take the URL
of this page (which you didn't tell us) and see what you get by
following each link. The LiveHTTPHeaders extension for Firefox is worth
using for this.
 
B

Brian Cryer

Dave said:
Hi,

Can anyone tell me the difference between the following where
"Test.asp" is found in the same folder as the target page calling the
hyperlink "Last Image"?

1. <a href="./Test.csp">Last Image</a>
2. <a href="Test.asp">Last Image</a>

Thanks in advance,
Dave

One is two characters longer than the other.

Seriously, I think that is the only difference. A single dot "." is a
reference to the current directory (similar to ".." referring to the
parent), so "./Test.csp" is the same as "Test.csp".
 
B

Brian Cryer

Brian Cryer said:
One is two characters longer than the other.

Seriously, I think that is the only difference. A single dot "." is a
reference to the current directory (similar to ".." referring to the
parent), so "./Test.csp" is the same as "Test.csp".

oops. Except, as pointed out by Andy, had I put my glasses on I would have
noticed one was .csp and the other .asp. (silly me). Nevertheless,
"./Test.csp" is the same as "Test.csp".
 
M

Michael Winter

Dave said:
Can anyone tell me the difference between the following where
"Test.asp" is found in the same folder as the target page calling the
hyperlink "Last Image"?

1. <a href="./Test.csp">Last Image</a>
2. <a href="Test.asp">Last Image</a>

Ignoring the typo (".csp" vs. ".asp"), there is no difference. A single
dot (.), as the only character in a path segment[1], simply refers to
the "same" path segment. It's just stripped out, though it can be
useful[2] on rare occasions.

With a base URI of:

http://www.example.com/foo/

all of:

bar/baz.html
./bar/baz.html
bar/./baz.html
./bar/./baz.html

resolve to:

http://www.example.com/foo/bar/baz.html

Section 5.4 Reference Resolution Examples of RFC 3986 shows several
examples of dot-segment resolution.

Mike


[1] Along with "..", these are also known as dot-segments.
[2] A relative-path reference cannot start with a path segment
that contains a colon as this would look like a URI starting
with a scheme:

foo:bar/baz.html (scheme: "foo", path: "bar/baz.html")

To make the relative nature of the reference explicit, it can
be prefixed with a "." dot-segment:

./foo:bar/baz.html
 
R

richard

Dave said:
Hi,

Can anyone tell me the difference between the following where
"Test.asp" is found in the same folder as the target page calling the
hyperlink "Last Image"?

1. <a href="./Test.csp">Last Image</a>
2. <a href="Test.asp">Last Image</a>

Thanks in advance,
Dave

Either can be used, but 2 distinctively tells the coding to look in this
folder.
As I've always understood it, the / means another folder or directory.
The dot says, "backup one level then use this directory or folder".
A leftover shortcut from DOS.
 
J

Jonathan N. Little

richard said:
Either can be used, but 2 distinctively tells the coding to look in this
folder.
As I've always understood it, the / means another folder or directory.
The dot says, "backup one level then use this directory or folder".
A leftover shortcut from DOS.
Close but not quite:

one dot './' means this folder in DOS
2 dots '../' means backup one level in DOS
 
A

Alan J. Flavell

On Thu, 21 Sep 2006, richard wrote:

[otiose quotage snipped yet again. Isn't it time you started
following good usenet netiquette?]
As I've always understood it, the / means another folder or
directory.

No. URLs (which is what these are) define their own hierarchy, which,
in principle, is completely independent of any server-specific file
system, folders etc. The data might not be stored in ordinary files
at all, but might be in a database, or be generated on-the-fly from
some other source.

In practice you will, of course, often find that the server is
configured so that a certain sub-tree of the server's file hierarchy
is mapped to a corresponding sub-tree of URLs, but this is by no means
fundamental to the web. Quite the contrary, in fact (the URL
hierarchy is not meant to expose internal details of web server file
hierarchies etc.). As long as one misses this distinction, things may
appear to be going just fine for quite a while, but sooner or later
there will be a big surprise.
A leftover shortcut from DOS.

I think the original designers of the URL scheme would quite resent
your implications.
 
J

Jukka K. Korpela

Andy said:
Otherwise the resolution of the URLs ought to point to the same
directory.

No, the resolution of the relative URLs produces the same _absolute URL_.
Whether the server happens to treat it as referring to a directory is just
coincidental (see Alan Flavell's reply).
As to the actuality for your real server, then take the URL
of this page (which you didn't tell us) and see what you get by
following each link.

The server is not involved in any way in the URL resolution business, which
is just string manipulation carried out by the _browser_. Only after
resolving the absolute URL will the browser try to contact the server, and
the server only gets the resolved absolute URL (split into parts, but that's
irrelevant here).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top