[support] Path trailing slash
John Fletcher
net at twoedged.org
Mon May 5 00:38:56 UTC 2008
Well that was an exciting discussion. Actually Michelle and others were right - it does actually work as I had hoped. So I'm happy. I must have never actually tested just putting a trailing slash on the URL!
In response to Morbus: Traditionally websites in HTML were built around a literal directory and file structure. A website would normally have an index document for each of its folders. I know Drupal is not built around a literal structure. But the user does not realise they are interacting with a Drupal site and thus may assume the literal folder structure and try to "hack the URL" as Greg called it.
Granted, if you site navigation is good enough they should never have to try this. Anyway as said I now know I can build my paths in a way that all my URLs will be "hackable", so thanks everyone.
Regards,
John.
-----Original Message-----
From: Morbus Iff [mailto:morbus at disobey.com]
Sent: Monday, 5 May 2008 12:46 AM
To: support at drupal.org
Subject: Re: [support] Path trailing slash
> what the website is about. So I go up a few folders manually... eg. I read
>
> www.example.com/articles/internet/whyinternetisgood.html, then
> I manually enter the following into the URL: www.example.com/articles/
> in order to see the index page containing all the articles.
>
> This reflects the basic function of HTML/HTTP. Obviously Drupal doesn�t
Unofrtunately, you're very confused. This is not a basic function of
HTML and HTTP but, rather, a side-effect of how the Apache webserver
handles filesystem requests. In short: if the requested destination maps
to a directory, then *Apache* (the webserver, not your browser, not the
website software) will append a trailing slash - to indicate that this
is a directory.
In a traditional Drupal example:
http://www.example.com/node/123
http://www.example.com/node
Neither of those Drupal URLs map to any literal file or directory on the
file system Your base assumption - that you can then "go up a few
folders" is inherently inaccurate, because *there are no folders*.
Take a look, for example, at:
http://www.disobey.com/detergent
This is a literal directory on my filesystem. If you attempt to go to
that URL, you will see that Apache (the webserver) will issue an
immediate and barely perceptible redirect which will send your browser
to the URL with a trailing slash instead. Apache will *only* ever do
this for directories. It's not going to do this for URLs served from a
website's content management system, such as example.com/node above.
This even works for the base URL:
http://www.disobey.com
Notice there's no trailing slash - but, if you enter just the above into
a browser, you'll see that Apache does the same barely perceptible
redirect and you'll reach http://www.disobey.com/. One could almost
infer that you can save scant ten thousandths of a second if you always
append literal directories with a trailing slash - if you don't, Apache
will just have to do it for you anyways (note that I've been following
this practice forever - see my signature for instance).
As Michelle followed up, though, Drupal, the website software, will
gladly accept a trailing slash *if the requested destination has content
to serve*. Both of these URLs work:
http://www.disobey.com/node
http://www.disobey.com/node/
Drupal is making them work because it knows that "node" is a valid
destination inside the software. Compare, on the other hand:
http://www.disobey.com/taxonomy/term/18
http://www.disobey.com/taxonomy/term/18/
Both of those URLs work, but not this one:
http://www.disobey.com/taxonomy/term
http://www.disobey.com/taxonomy/term/
Because there's nothing inside Drupal that exists at that destination
(thus, it gives the standard "Page not found" error). You would
certainly, however, be able to define your own node, and then alias both
of the above URLs, if you so chose.
Your biggest problem is, however:
* You've misunderstood that path components of a URL directly
map to a filesystem's directory/file structure; they don't.
* You've misunderstood that *every* literal directory/file
structure allows you to browse up the hierarchy by just
removing parts of the path. Compare, for example:
http://www.disobey.com/misc/druplicon.png
http://www.disobey.com/misc/
These are literal files and directories, but one can't browse
the /misc/ directory (in this case, because it's been denied,
but whether Apache's DirectoryIndex is properly configured is
also another measure of success).
* You've misunderstood that Drupal (or any website software)
can't replicate this functionality; it can.
--
Morbus Iff ( est quaedam flere voluptas )
Technical: http://www.oreillynet.com/pub/au/779
Enjoy: http://www.disobey.com/ and http://www.videounderbelly.com/
aim: akaMorbus / skype: morbusiff / icq: 2927491 / jabber.org: morbus
More information about the support
mailing list