472,119 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

links to current directory in html


about href links to other html pages in current directory:

w3c seems to recommond using ./pagename
and just pagename works too.

Is there any actual difference in these two?
I think no in Windows, but less sure about Unix.

what about links back to main page?

Is ./ any better than ./index.html ?

I assume all are much better than http://www.domainname.com
to avoid DNS lookup.

Apr 24 '06 #1
4 6552
Wayne wrote:
about href links to other html pages in current directory:

w3c seems to recommond using ./pagename
and just pagename works too.
Where exactly did you find such a recommendation?
Is there any actual difference in these two?
I think no in Windows, but less sure about Unix.
The OS is irrelevant, it would be defined by the relevant RFC for URIs.
what about links back to main page?

Is ./ any better than ./index.html ?
Assuming the page is being served from a web server (not just read from
the local file system) then "./" is better if you want to link to the
index of the current directory and, similarly, just "/" when you want to
link to the root directory. From the local file system, you don't have
much choice about including index.html because it typically won't work
without it.

That's because "index.html" is unnecessary and because if you change
server or implementation details e.g. switch to IIS which typically uses
default.htm or switch to a server side technology like PHP (index.php),
then it's easier to avoid changing URIs and setting up redirects.
I assume all are much better than http://www.domainname.com
to avoid DNS lookup.


DNS lookup is irrelvant, the URI you use in the markup makes no
difference. If the page is served from that the domain, then (in the
absense of a <base> element or xml:base attribute that says otherwise)
any relative URIs will resolve to that domain anyway and the browser
will retrive it in exactly the same way. It's just unnecessary to
include the domain in links to the same server.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Apr 24 '06 #2
Dan

Wayne wrote:
Is ./ any better than ./index.html ?


I discuss this issue in my Web Tips site:
http://webtips.dan.info/subdir.html

--
Dan

Apr 24 '06 #3
In article <11*********************@t31g2000cwb.googlegroups. com>,
da*@tobias.name says...
I discuss this issue in my Web Tips site:
http://webtips.dan.info/subdir.html

Thanks Dan. I had not considered if the browser might consider it a
different file name or not.

Lachlan, that "recommendation" was just my own judgement, but I
reference the example at
http://www.w3.org/TR/REC-html40/struct/links.html
almost halfway down the page, where it says:
'Thus, a link defined in the file "two.html" in the same directory as
"one.html" would refer to the anchor as follows:'

Apr 24 '06 #4
Wayne wrote:
about href links to other html pages in current directory:

w3c seems to recommond using ./pagename
and just pagename works too.
Is there any actual difference in these two?
None. With no leading path "./" is implied.
what about links back to main page?
What about them?
I assume all are much better than http://www.domainname.com
to avoid DNS lookup.

Not really. Only the first instance requires a lookup. After that the
result is cached.
Not using a "http://example.com/" offers a maintenance advantage. Having
a local site that reflects the public site's structure is a lot easier to
maintain. The same code works at both sites.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Apr 24 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Chris | last post: by
9 posts views Thread by Alex Bell | last post: by
1 post views Thread by John Seeliger | last post: by
6 posts views Thread by titan.nyquist | last post: by
7 posts views Thread by David Stone | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.