You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by David Holden <dv...@gmail.com> on 2005/08/24 13:20:08 UTC

[users@httpd] Which file gets served when the URL does not include a mime type extension.

Hello,

 If I have a directory "test" with two files in "file.xml" and
"file.html" can anyone tell me which should get served if I address it
from a browser using

"http://localhost/test/file"

i.e. without specifying the suffix.

also is this behaviour configurable?

thanks,

        Dave.



--
Dr. David Holden.
Please avoid sending me Word or PowerPoint attachments, thanks.
See: <http://www.gnu.org/philosophy/no-word-attachments.html>
Public GPG key available on request.
-------------------------------------------------------------

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Which file gets served when the URL does not include a mime type extension.

Posted by David Holden <dv...@gmail.com>.
Yes  content negotiation is what was happening as I had Multiviews on
in the conf file.

 Thanks 
 
        Dave.

On 8/24/05, oxfordmusic.net <li...@oxfordmusic.net> wrote:
> >
> > thanks for the reply, the reason I ask is because I'm getting a
> > default behaviour that I cannot find documentation of.
> >
> > i.e. if I sent up a server with these two files in a directory it is
> > always serving the XML file over the HTML file.
> >
> > e.g
> >
> > http://localhost/test/file
> >
> > will return file.xml not file.html
> >
> > I don't think "DirectoryIndex" is appropriate here because the file
> > name does not matter, e.g. it could be fred.xml/fred.html or
> > bill.xml/bill.html it still chooses the .xml file over the html file
> > if both are there..
> >
> 
> correct. "DirectoryIndex" is not approariate here. that only governs the
> behaviour when http://localhost/test is requested.
> what you need to read up on is Content Negotiation:
> http://www.google.co.uk/search?hl=en&q=apache+content+negotiation&btnG=Google+Search&meta=
> which is how the server decides which file to server based on what the
> browser has requested and your own rules.
> a simple way to define it is, i believe, to place a file called file.var in
> the same directory with contents something like this:
> 
> URI: file
> 
> URI: file.html
> Content-type: text/html; qs=1
> 
> i am by no means an expert but this should at least give you something to
> get started on.
> 
> andy
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 


-- 
-- 
Dr. David Holden.
Please avoid sending me Word or PowerPoint attachments, thanks.
See: <http://www.gnu.org/philosophy/no-word-attachments.html>
Public GPG key available on request.
-------------------------------------------------------------

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Which file gets served when the URL does not include a mime type extension.

Posted by "oxfordmusic.net" <li...@oxfordmusic.net>.
>
> thanks for the reply, the reason I ask is because I'm getting a
> default behaviour that I cannot find documentation of.
>
> i.e. if I sent up a server with these two files in a directory it is
> always serving the XML file over the HTML file.
>
> e.g
>
> http://localhost/test/file
>
> will return file.xml not file.html
>
> I don't think "DirectoryIndex" is appropriate here because the file
> name does not matter, e.g. it could be fred.xml/fred.html or
> bill.xml/bill.html it still chooses the .xml file over the html file
> if both are there..
>

correct. "DirectoryIndex" is not approariate here. that only governs the 
behaviour when http://localhost/test is requested.
what you need to read up on is Content Negotiation:
http://www.google.co.uk/search?hl=en&q=apache+content+negotiation&btnG=Google+Search&meta=
which is how the server decides which file to server based on what the 
browser has requested and your own rules.
a simple way to define it is, i believe, to place a file called file.var in 
the same directory with contents something like this:

URI: file

URI: file.html
Content-type: text/html; qs=1

i am by no means an expert but this should at least give you something to 
get started on.

andy 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Which file gets served when the URL does not include a mime type extension.

Posted by David Holden <dv...@gmail.com>.
Hi Tony,

 thanks for the reply, the reason I ask is because I'm getting a
default behaviour that I cannot find documentation of.

i.e. if I sent up a server with these two files in a directory it is
always serving the XML file over the HTML file.

e.g

http://localhost/test/file

will return file.xml not file.html

I don't think "DirectoryIndex" is appropriate here because the file
name does not matter, e.g. it could be fred.xml/fred.html or
bill.xml/bill.html it still chooses the .xml file over the html file
if both are there..

 Dave.




On 8/24/05, Tony VanScoy <tv...@gmail.com> wrote:
> >  If I have a directory "test" with two files in "file.xml" and
> > "file.html" can anyone tell me which should get served if I address it
> > from a browser using
> >
> > "http://localhost/test/file"
> >
> > i.e. without specifying the suffix.
> >
> > also is this behaviour configurable?
> >
> > thanks,
> >
> >         Dave.
> 
> Maybe you're looking for DirectoryIndex.
> 
> <Location /test>
>   DirectoryIndex file.xml file.html
> </Location>
> 
> With that config, Apache will look for file.xml first, and then
> file.html if the first is not found. As far as serving up file.xml
> when only "file" is requested, you could do something with
> mod_rewrite.
> 
> RewriteRule ^/test/file$ /test/file.xml  <- will use file.xml for
> "http://localhost/test/file"
> 
> .. or something like that. Check the syntax
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 


-- 
-- 
Dr. David Holden.
Please avoid sending me Word or PowerPoint attachments, thanks.
See: <http://www.gnu.org/philosophy/no-word-attachments.html>
Public GPG key available on request.
-------------------------------------------------------------

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Which file gets served when the URL does not include a mime type extension.

Posted by Tony VanScoy <tv...@gmail.com>.
>  If I have a directory "test" with two files in "file.xml" and
> "file.html" can anyone tell me which should get served if I address it
> from a browser using
> 
> "http://localhost/test/file"
> 
> i.e. without specifying the suffix.
> 
> also is this behaviour configurable?
> 
> thanks,
> 
>         Dave.

Maybe you're looking for DirectoryIndex.

<Location /test>
  DirectoryIndex file.xml file.html
</Location>

With that config, Apache will look for file.xml first, and then
file.html if the first is not found. As far as serving up file.xml
when only "file" is requested, you could do something with
mod_rewrite.

RewriteRule ^/test/file$ /test/file.xml  <- will use file.xml for
"http://localhost/test/file"

.. or something like that. Check the syntax

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org