./ = index.html

Post here if your topic is about CSS HTML Validator but doesn't fit in another forum.
Post Reply
User avatar
roedygr
Rank V - Professional
Rank V - Professional
Posts: 372
Joined: Fri Feb 17, 2006 5:22 am
Location: Victoria BC Canada
Contact:

./ = index.html

Post by roedygr » Tue Apr 22, 2014 3:45 am

HTMLValidator asked me to read http://webtips.dan.info/subdir.html#LinkHome

It asked me to replace all links of the form ../../../index.html with ./

To my astonishment, this trick works both on the web and locally.

The puzzle is, how does the browser know in which directory to look for the index.html?
Is it always the one directory off the root. Does it search the chain of directories back looking for an index.html?
Is this supposed to work if you have embedded index.html files in the tree to discourage directory listing?

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3344
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: ./ = index.html

Post by Albert Wiersch » Tue Apr 22, 2014 7:45 am

If you have href="../../../index.html", then it is recommending that you replace it with href="../../../", not with href="./".

I would also be amazing if you could replace href="../../../index.html" with href="./". :D

If that works, then there must be a good reason why it's working in your case.
Image
Albert Wiersch

User avatar
roedygr
Rank V - Professional
Rank V - Professional
Posts: 372
Joined: Fri Feb 17, 2006 5:22 am
Location: Victoria BC Canada
Contact:

Re: ./ = index.html

Post by roedygr » Tue Apr 22, 2014 1:10 pm

I have done a number of experiments and I found ./ only works in the root directory. Elsewhere you must use ../.././ etc.

I could not repeat my strange results of jumping home successfully with ./ from E:\mindprod\jgloss\jgloss.html

The catch is, browsers don't understand what it means when serving the website from local files -- what you do when composing or when you distribute mirrors. I had to put it all back to index.html (not hard, all the code was in one spot).

If you were very keen on using it, you might use a local Tomcat server running on your own PC whose job is to make the website behave identically locally and on the web, including ads, google 1+ etc.

The essay htlml validator directed me to made it sound as if you could put ./ on ANY page at any depth and it would go home. For that to work, there would have to be some mechanism for a browser to figure out which directory is home. I could not find one.

I work with urls of the form jgloss/jdk.html in my markup and mechanically convert them to ../.. relative links.
The corresponding url on the website is http://mindprod.com/jgloss/jdk.html
The corresponding local file is called e:\mindprod\jgloss\jdk.html

I have often wished I could directly use urls like /jgloss/jdk.html in my markup, but they do not work.
Does that format have an official name?

Have you ever thought of a mechanism so that a browser could handle a local website with more aplomb.
There would be a file you configure to use the files for local use. It would contain things like
where the home directory is.
where the corresponding web version is.
the extension to mime tables.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3344
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: ./ = index.html

Post by Albert Wiersch » Tue Apr 22, 2014 7:33 pm

Yes, this is limited to working with web servers and will likely not work if the HTML is being viewed locally from a local file system without a web server.

A path that starts with '/' is not relative to the current document but you might say it's relative to the site's root. I'm not aware of any official name for this type of path though. Maybe a "root relative" path?

I'm not sure what you mean by a mechanism for a browser to handle a local website better, but CSE HTML Validator has a path mapping feature so you can create some path maps for it to be able to properly resolve absolute link paths for link checking.
Image
Albert Wiersch

Post Reply