Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

trailing slash in web urls

 
Goto page 1, 2
   Soft32 Home -> Linux -> Genreal Discussions RSS
Next:  Need advice on linux distro  
Author Message
alias

External


Since: Jun 30, 2003
Posts: 2



(Msg. 1) Posted: Sun Jun 29, 2003 10:58 pm
Post subject: trailing slash in web urls
Archived from groups: alt>os>linux (more info?)

ya this may be a lame question but i have just setup apache 2.0.46 and
when i connect to http://domain it gets the index just fine but lets say
i go and try to get http://domain/test it will not look in the directory
to find the index files but if i put the trailing slash it works fine.
this is on Apache/2.0.46 (Gentoo/Linux) mod_ssl/2.0.46 OpenSSL/0.9.6i
PHP/4.3.2

thanks in advance
Regards
bkeep
Back to top
Login to vote
Julian Baldwin

External


Since: Jun 27, 2003
Posts: 4



(Msg. 2) Posted: Mon Jun 30, 2003 11:36 am
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 30 Jun 2003 13:58:44 +1000, alias wrote:

> ya this may be a lame question but i have just setup apache 2.0.46 and
> when i connect to http://domain it gets the index just fine but lets say
> i go and try to get http://domain/test it will not look in the directory
> to find the index files but if i put the trailing slash it works fine.
> this is on Apache/2.0.46 (Gentoo/Linux) mod_ssl/2.0.46 OpenSSL/0.9.6i
> PHP/4.3.2

This happens because without the slash Apache attempts to find a _file_
called 'test'. When you put the slash on the end, the server looks for a
directory. I don't know if you can do anything about that, except for a
symlink to the right directory.

JB
Back to top
Login to vote
Joachim Feise

External


Since: Jun 26, 2003
Posts: 4



(Msg. 3) Posted: Mon Jun 30, 2003 11:36 am
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Julian Baldwin wrote:
> On Mon, 30 Jun 2003 13:58:44 +1000, alias wrote:
>
>
>>ya this may be a lame question but i have just setup apache 2.0.46 and
>>when i connect to http://domain it gets the index just fine but lets say
>>i go and try to get http://domain/test it will not look in the directory
>>to find the index files but if i put the trailing slash it works fine.
>>this is on Apache/2.0.46 (Gentoo/Linux) mod_ssl/2.0.46 OpenSSL/0.9.6i
>>PHP/4.3.2
>
>
> This happens because without the slash Apache attempts to find a _file_
> called 'test'. When you put the slash on the end, the server looks for a
> directory. I don't know if you can do anything about that, except for a
> symlink to the right directory.

If Apache doesn't find a file with the proper name, it assumes that the
URL refers to a directory, and sends a redirect (code 301).

-Joe
Back to top
Login to vote
David Efflandt

External


Since: Feb 26, 2005
Posts: 17



(Msg. 4) Posted: Mon Jun 30, 2003 11:36 am
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 30 Jun 2003, Julian Baldwin <julianb RemoveThis @student.unsw.edu.auNOSPAM> wrote:
> On Mon, 30 Jun 2003 13:58:44 +1000, alias wrote:
>
>> ya this may be a lame question but i have just setup apache 2.0.46 and
>> when i connect to http://domain it gets the index just fine but lets say
>> i go and try to get http://domain/test it will not look in the directory
>> to find the index files but if i put the trailing slash it works fine.
>> this is on Apache/2.0.46 (Gentoo/Linux) mod_ssl/2.0.46 OpenSSL/0.9.6i
>> PHP/4.3.2
>
> This happens because without the slash Apache attempts to find a _file_
> called 'test'. When you put the slash on the end, the server looks for a
> directory. I don't know if you can do anything about that, except for a
> symlink to the right directory.

No, usually apache recognized it is a directory and tries to fix the
invalid URL by attempting to redirect to http://$ServerName/test/

The problem comes when the client cannot resolve the set ServerName (or
hostname if unset) or it is localhost (which would point to client instead
of server). See docs for UseCanonicalName (setting that off can help).

--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
Back to top
Login to vote
alias

External


Since: Jun 30, 2003
Posts: 2



(Msg. 5) Posted: Mon Jun 30, 2003 12:05 pm
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

David Efflandt wrote:
> On Mon, 30 Jun 2003, Julian Baldwin <julianb.DeleteThis@student.unsw.edu.auNOSPAM> wrote:
>
>>On Mon, 30 Jun 2003 13:58:44 +1000, alias wrote:
>>
>>
>>>ya this may be a lame question but i have just setup apache 2.0.46 and
>>>when i connect to http://domain it gets the index just fine but lets say
>>>i go and try to get http://domain/test it will not look in the directory
>>>to find the index files but if i put the trailing slash it works fine.
>>>this is on Apache/2.0.46 (Gentoo/Linux) mod_ssl/2.0.46 OpenSSL/0.9.6i
>>>PHP/4.3.2
>>
>>This happens because without the slash Apache attempts to find a _file_
>>called 'test'. When you put the slash on the end, the server looks for a
>>directory. I don't know if you can do anything about that, except for a
>>symlink to the right directory.
>
>
> No, usually apache recognized it is a directory and tries to fix the
> invalid URL by attempting to redirect to http://$ServerName/test/
>
> The problem comes when the client cannot resolve the set ServerName (or
> hostname if unset) or it is localhost (which would point to client instead
> of server). See docs for UseCanonicalName (setting that off can help).
>

yes the UseConicalNames set to off seemed to fix my problem thanks alot

regards
bkeep
Back to top
Login to vote
Julian Baldwin

External


Since: Jun 27, 2003
Posts: 4



(Msg. 6) Posted: Mon Jun 30, 2003 1:32 pm
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 30 Jun 2003 18:18:32 +1000, Joachim Feise wrote:

> If Apache doesn't find a file with the proper name, it assumes that the
> URL refers to a directory, and sends a redirect (code 301).

Ooops - sorry! Could you use a symlink to 'fix' it though?

JB
Back to top
Login to vote
Joachim Feise

External


Since: Jun 26, 2003
Posts: 4



(Msg. 7) Posted: Mon Jun 30, 2003 1:32 pm
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Julian Baldwin wrote:
> On Mon, 30 Jun 2003 18:18:32 +1000, Joachim Feise wrote:
>
>
>>If Apache doesn't find a file with the proper name, it assumes that the
>>URL refers to a directory, and sends a redirect (code 301).
>
>
> Ooops - sorry! Could you use a symlink to 'fix' it though?

It is not broken, so there is nothing to fix.
A symlink is resolved before it is used, so you'd have the same issue.
Simply use URLs correctly, i.e., add a slash if your URL points to
a directory.

-Joe
Back to top
Login to vote
Sybren Stuvel

External


Since: Jun 22, 2003
Posts: 8



(Msg. 8) Posted: Mon Jun 30, 2003 1:32 pm
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Julian Baldwin enlightened us with:
> Ooops - sorry! Could you use a symlink to 'fix' it though?

You don't want to "fix" it. If you link to a directory, add a slash. If
you link to a file, don't add a slash. If you build your hyperlinks
right, your server will be faster because it won't need to send the
redirects and handle the extra requests in the first place. It's that
little bit of extra time you'll have to invest, which will give you a
small speed boost. Trying to fix something that isn't broken will only
slow things down, and if you do that too many times, you'll end up
with something that could have been built by microsoft.

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Back to top
Login to vote
Julian Baldwin

External


Since: Jun 27, 2003
Posts: 4



(Msg. 9) Posted: Tue Jul 01, 2003 8:06 am
Post subject: Re: trailing slash in web urls [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, 01 Jul 2003 01:25:05 +1000, Joachim Feise wrote:

> It is not broken, so there is nothing to fix. A symlink is resolved
> before it is used, so you'd have the same issue. Simply use URLs
> correctly, i.e., add a slash if your URL points to a directory.

Yeah, I realised that almost straight after I hit 'post'. Can't talk
right now, cause I have a big foot in my mouth. Sorry everybody Wink

JB
Back to top
Login to vote
... et al.

External


Since: Jul 04, 2003
Posts: 4



(Msg. 10) Posted: Fri Jul 04, 2003 2:45 pm
Post subject: Re: trailing slash in web urls (and in Linux paths?) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Joachim Feise <reply DeleteThis @the.newsgroup> wrote:

> Simply use URLs correctly, i.e., add a slash if your URL points to
> a directory.

I totally sympathise with the explanation by you and Sybren Stuvel. And
the reasoning why slashes (instead of backslashes or colons) is used, is
that internet, the HTTProtocol and webbrowsing all where developed on
systems running Unix-style OS's, right?

As a person that want's to understand Linux, this then brings me to be
harassed by another question.

Then, .. in the name of logic .., shouldn't the same rule apply to all
paths in Unix (read Linux) as well? As in, for example, "You would
usually find foo in /bar/ or somtimes under /bar/subbar/" But i don't
think i've ever seen it like that in books or by knowledgeble people in
the various Linux newsgroups i am lurking in. It is always just "/bar"
and "/bar/subbar" without the trailing slashes when naming directories.

I'm afraid the answer might have to do with the "in Unix everything is a
file" statement? As in, also directories are files. ¡But even more
unlogical then!, there _is one_ directory where the trailing slash
actually always _is_ used [1].

Isn't this ¿(seeming)? discrepancy bugging anyone but me?



[1] That would be the root-directory, the slash-directory, the "/".

--
Please followup in newsgroup.
E-mail address is invalid due to spam-control.
Back to top
Login to vote
Peter T. Breuer

External


Since: Aug 19, 2003
Posts: 22



(Msg. 11) Posted: Fri Jul 04, 2003 3:05 pm
Post subject: Re: trailing slash in web urls (and in Linux paths?) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

.... et al. <look DeleteThis @sig.bcause.this.is.invalid> wrote:
> Joachim Feise <reply DeleteThis @the.newsgroup> wrote:

>> Simply use URLs correctly, i.e., add a slash if your URL points to
>> a directory.

> I totally sympathise with the explanation by you and Sybren Stuvel. And
> the reasoning why slashes (instead of backslashes or colons) is used, is
> that internet, the HTTProtocol and webbrowsing all where developed on
> systems running Unix-style OS's, right?

No. Quite the opposite. The slash is so that systems which don't have
the same kind of file structure know to do a getdents instead of a
lstat. Remember that URLs have to work on embedded smartcard
applications too, and there ain't a lot of code available in your
magnetic stripe.

Anyway, unix servers generally translate to the right call for you.

> As a person that want's to understand Linux, this then brings me to be
> harassed by another question.

> Then, .. in the name of logic .., shouldn't the same rule apply to all
> paths in Unix (read Linux) as well? As in, for example, "You would

Paths are a question for your shell, not of unix. But yes, there is a
posix shell, and ...

> usually find foo in /bar/ or somtimes under /bar/subbar/" But i don't

... this is quite correct usage. The shell normally translates for you,
however. There are a few occasions when you will get different answers
from ls foo than ls foo/, but not many. ls -l of a softlink to a
directory springs to mind.

> think i've ever seen it like that in books or by knowledgeble people in

Sure you have. Most people write it like that when they want to be
clear.

> the various Linux newsgroups i am lurking in. It is always just "/bar"
> and "/bar/subbar" without the trailing slashes when naming directories.

No it isn't.

> I'm afraid the answer might have to do with the "in Unix everything is a
> file" statement? As in, also directories are files. But even more
> unlogical then!, there _is one_ directory where the trailing slash
> actually always _is_ used [1].

I don't understand your problem. You are basing your reasoning on
false aprehensions. And even if your hypoteheses were right, so what?
The shell is free to help you out whenever it feels like.


> Isn't this (seeming)? discrepancy bugging anyone but me?

>

> [1] That would be the root-directory, the slash-directory, the "/".

No - that would be "//" following your nomenclature. Indeed, it is, in
URLs. Try

lynx file:///

and

lynx file://

and tell me which works as you expect!



Peter
Back to top
Login to vote
David Efflandt

External


Since: Feb 26, 2005
Posts: 17



(Msg. 12) Posted: Fri Jul 04, 2003 7:21 pm
Post subject: Re: trailing slash in web urls (and in Linux paths?) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Fri, 4 Jul 2003, ... et al. <look RemoveThis @sig.bcause.this.is.invalid> wrote:
> Joachim Feise <reply RemoveThis @the.newsgroup> wrote:
>
>> Simply use URLs correctly, i.e., add a slash if your URL points to
>> a directory.
>
> I totally sympathise with the explanation by you and Sybren Stuvel. And
> the reasoning why slashes (instead of backslashes or colons) is used, is
> that internet, the HTTProtocol and webbrowsing all where developed on
> systems running Unix-style OS's, right?
>
> As a person that want's to understand Linux, this then brings me to be
> harassed by another question.
>
> Then, .. in the name of logic .., shouldn't the same rule apply to all
> paths in Unix (read Linux) as well? As in, for example, "You would
> usually find foo in /bar/ or somtimes under /bar/subbar/" But i don't
> think i've ever seen it like that in books or by knowledgeble people in
> the various Linux newsgroups i am lurking in. It is always just "/bar"
> and "/bar/subbar" without the trailing slashes when naming directories.

I was following this earlier, but must have missed something in the
middle. The reason URLs need a slash following a directory is so relative
links work properly. For example if you went to http://hostname/foo and
that had a link to bar, how would the browser determine whether foo was a
file (or script) or a directory. In other words how would the browser
know if it should go to http://hostname/bar or http://hostname/foo/bar?

If you initially went to http://hostname/foo/ it would be quite clear
where to go to find a relative link to bar.

Since the webserver (or any shell user) can tell whether the requested
resource is a file or dir, it will usually redirect to the corrected path.
However, server settings determine whether it is redirected to the main
ServerName or the host supplied by the browser Host header. If that is
misconfigured (like private hostname that does not resolve or localhost)
the browser can be redirected to the wrong host or no host. If you use a
valid URL in the first place, it will not be redirected to a possibly
incorrect location.

You are perfectly in your right to question the rules. But once you
understand why they apply, you will better see why you should accept them
where they belong, and not try to apply them to a different context where
they are not an issue. A Unix system knows if something is a file or
dir, a web browser cannot tell without the trailing slash. And even then
it does not really matter if it is a dir, or PATH_INFO, just so relative
paths work.

--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
Back to top
Login to vote
Joachim Feise

External


Since: Jun 26, 2003
Posts: 4



(Msg. 13) Posted: Sat Jul 05, 2003 3:37 am
Post subject: Re: trailing slash in web urls (and in Linux paths?) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Peter T. Breuer wrote:
> ... et al. <look DeleteThis @sig.bcause.this.is.invalid> wrote:
>
>>Joachim Feise <reply DeleteThis @the.newsgroup> wrote:
>
>
>>>Simply use URLs correctly, i.e., add a slash if your URL points to
>>>a directory.
>
>
>>I totally sympathise with the explanation by you and Sybren Stuvel. And
>>the reasoning why slashes (instead of backslashes or colons) is used, is
>>that internet, the HTTProtocol and webbrowsing all where developed on
>>systems running Unix-style OS's, right?
>
>
> No. Quite the opposite. The slash is so that systems which don't have
> the same kind of file structure know to do a getdents instead of a
> lstat. Remember that URLs have to work on embedded smartcard
> applications too, and there ain't a lot of code available in your
> magnetic stripe.
>
> Anyway, unix servers generally translate to the right call for you.

Actually, when I said "add a slash if your URL points to a directory", I
was a bit sloppy, in order to get the point across.
A webserver is not a file system, so it does not have the concept of
directories. It has the concept of resources and collections of
resources. It just happens that this is *usually* mapped to the filesystem,
and it is pretty much a natural mapping.
But nobody prevents you to create your resources and collections on the fly,
without any specific filesystem mapping.
You address collections (which may be mapped to directories in a filesystem)
with URLs that end with a slash.
The slash is a generic separator in a hierarchical tree of collections.

-Joe
Back to top
Login to vote
Lew Pitcher

External


Since: Jul 19, 2003
Posts: 3



(Msg. 14) Posted: Sat Jul 05, 2003 12:19 pm
Post subject: Re: trailing slash in web urls (and in Linux paths?) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Without hesitation, ... et al. asserted (on or about 07/04/03 13:45) that:
> Joachim Feise <reply.RemoveThis@the.newsgroup> wrote:
>
>
>>Simply use URLs correctly, i.e., add a slash if your URL points to
>>a directory.
>
>
> I totally sympathise with the explanation by you and Sybren Stuvel. And
> the reasoning why slashes (instead of backslashes or colons) is used, is
> that internet, the HTTProtocol and webbrowsing all where developed on
> systems running Unix-style OS's, right?

Nope.

> As a person that want's to understand Linux, this then brings me to be
> harassed by another question.
>
> Then, .. in the name of logic .., shouldn't the same rule apply to all
> paths in Unix (read Linux) as well?

Nope.


--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
Back to top
Login to vote
... et al.

External


Since: Jul 04, 2003
Posts: 4



(Msg. 15) Posted: Sat Jul 05, 2003 11:17 pm
Post subject: Re: trailing slash in web urls (and in Linux paths?) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

David Efflandt <efflandt.RemoveThis@xnet.com> wrote:

> On Fri, 4 Jul 2003, ... et al. <look.RemoveThis@sig.bcause.this.is.invalid> wrote:
> > Joachim Feise <reply.RemoveThis@the.newsgroup> wrote:
> >
> >> Simply use URLs correctly, i.e., add a slash if your URL points to
> >> a directory.

<snip>

> > Then, .. in the name of logic .., shouldn't the same rule apply to all
> > paths in Unix (read Linux) as well?

<snip>

> I was following this earlier, but must have missed something in the
> middle.

Not necessarily. I just appended some thoughts to advice given, trying
to generalize to areas i thought were related. And i also changed the
subject of the thread.

> The reason URLs need a slash following a directory is so relative
> links work properly. For example if you went to http://hostname/foo and
> that had a link to bar, how would the browser determine whether foo was a
> file (or script) or a directory. In other words how would the browser
> know if it should go to http://hostname/bar or http://hostname/foo/bar?
>

This can't be correct, can it? My hypothesis has been that if the
web-server decides that http://hostname/foo was actually a
"directory-resource", http://hostname/foo/, it would serve the
client-browser with a resource of it's choosing, originally
http://hostname/foo/index.html, along with the path for that resource in
the HTTP-header, so that relative links within that resource would be
parsed correctly by the browser.

> If you initially went to http://hostname/foo/ it would be quite clear
> where to go to find a relative link to bar.
>

Writing http://hostname/foo/ does two good things in my opinion. It
makes the the server save time by not invainly trying to look for
http://hostname/foo, before doing whatever it is configured to do with
"directory-resources" (often serving the client a resource from within
that directory). And secondly it shows me, the non-computerized part in
the mix, more easily what kind of resource the link/path is pointing at.

> Since the webserver (or any shell user) can tell whether the requested
> resource is a file or dir, it will usually redirect to the corrected path.
> However, server settings determine whether it is redirected to the main
> ServerName or the host supplied by the browser Host header. If that is
> misconfigured (like private hostname that does not resolve or localhost)
> the browser can be redirected to the wrong host or no host. If you use a
> valid URL in the first place, it will not be redirected to a possibly
> incorrect location.
>
> You are perfectly in your right to question the rules. But once you
> understand why they apply, you will better see why you should accept them
> where they belong, and not try to apply them to a different context where
> they are not an issue.

The point of my post Smile To get comments and clarifications to my
ponderings to gain an understanding to how things work so i can make
more informed decisions as to how to "address" paths in linux, compared
to URL-type paths. (I am using, and have been for many years, trailing
slashes in URL's, as opposed to the majority of internet-users, whether
they should know better (e.g. website designers/authors) or not.)

> A Unix system knows if something is a file or dir,

Because in unix a directory is a file, ¿or how does that work? But
that's a separate thread. Wink

> a web browser cannot tell without the trailing slash. And even then
> it does not really matter if it is a dir, or PATH_INFO, just so relative
> paths work.

--
Please followup in newsgroup.
E-mail address is invalid due to spam-control.
Back to top
Login to vote
Display posts from previous:   
Related Topics:
acl and linux - hi, i have to work with acl and linux; how is the best file system to do it ? (i have heard reiserfs but i don't know....

Microsoft/LINUX debate. - Why does people brother having this Microsoft/LINUX mud-slinging thing? I am new to LINUX but installed REDHAT 8..

Multiple CD volume backup solution - Hi all I'm looking for a backup package that will allow me to span multiple CDs and also allow for individual CD..

virus scanner - Hi All was wondering if i can get some idea of what people are useing for virus scanners on Redhat 8. Its sendmail tha...

Need advice on linux distro - I Installed Debian Linux on a spare computer 2 months ago, and that was the first time I used linux. I've been using i...

Ymessenger or Gaim no sound. - Im trying to use yahoo messenger (0.99.19) and / or gaim (v0.64) on a RH8 system. I do have sound working on the..
       Soft32 Home -> Linux -> Genreal Discussions All times are: Pacific Time (US & Canada) (change)
Goto page 1, 2
Page 1 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]