Why directory URLs have to have trailing slashesWeb servers and many web applications are quite insistent that URLs that represent 'directories' have to end in a slash; if you request the URL without the trailing slash, they just give you a redirection to the same URL with a slash on the end instead of the actual content. One might well wonder why they have this neurotic insistence, especially when it complicates URL rewriting for applications that can do whatever they want with incoming URLs anyways. (The other side of this question is whether web applications have to care about this, and if they do, why.) The answer is that it's required in order to correctly resolve any
relative URLs in the document. Consider a 'directory' page (The official source for this whole process is RFC 2396, updating the original RFC 1808.) Whether this matters to your web application depends on what sort of links you generate. If you always use absolute paths, then you don't need to care; you can ignore the situation and give people the same contents regardless of the presence or absence of the trailing slash. If you do use relative links, then you need to notice the situation and either force the redirection or generate slightly different content. (I would suggest forcing the redirection on the grounds that it is less confusing to both Google and users; otherwise you have two URLs that are the same thing.) (This is one of those entries that I write to tack things down firmly in my mind, after a co-worker had to remind me of all of this.) (2 comments.)
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |