You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marco Scoffier <ma...@metm.org> on 2005/06/13 21:39:36 UTC

[users@httpd] still content negotiation problems

Hello,

I am stuck, I've read a lot of docs, and still it doesn't work.

I am trying to set up a site which will serve pages in french and
english.  I have read the pages at 
  http://httpd.apache.org/docs/content-negotiation.html
  http://httpd.apache.org/docs/mod/mod_mime.html#addlanguage
  http://httpd.apache.org/docs/mod/mod_negotiation.html
  http://ppewww.ph.gla.ac.uk/~flavell/www/lang-neg.html
  http://tranchant.plus.com/notes/multiviews

And the gmane.comp.apache.user archive of this list, and still my server
refuses to play nice, or the heat is making me stoopid...

What I have done so far (I was thinking of making a little toot cause
the documentation sure is lacking):

I'm using OpenBSD's apache (which does not have many "standard" modules
compiled):

  compiled mod_negotiation and mod_mime (which I am not 100% sure is needed):
    cd /usr/scr/usr.sbin/httpd/modules/standard
	apxs -i -a -c mod_negociation.c
	apxs -i -a -c mod_mime.c

apxs which I haven't used before puts the modules in
/usr/lib/apache/modules and adds the two LoadModule lines to
/var/www/conf/httpd.conf cool.

LoadModule negotiation_module /usr/lib/apache/modules/mod_negotiation.so
LoadModule mime_module        /usr/lib/apache/modules/mod_mime.so

(are there other modules I need ?)

    apachectl configtest 
    Syntax OK 

Haven't broken anything good.  Now for httpd.conf :

I want to keep much of the old site working.  If there was an index.html
version and there is no french version I would like index.html sent to
the browser.  If there is a index.html.fr I would like the negotiating
to happen sending the correct page depending Accept-Language header sent
out by the browser.  Seems that I have to then change the english
index.html to index.html.html and the french to index.html.fr
As per: http://ppewww.ph.gla.ac.uk/~flavell/www/lang-neg.html

<VirtualHost *>
        ServerName langnego.no-ip.org
        DocumentRoot /var/www/htdocs/langnego
        ErrorLog /var/www/logs/langnego.no-ip.org/error.log
        CustomLog /var/www/logs/langnego.no-ip.org/access.log "%h %l %u %t \"%r\" %s %b \"
%{User-agent}i\" \"%{Accept-language}i\""
</VirtualHost>

<Directory /var/www/htdocs/langnego/ >
        Options +MultiViews
        AddLanguage fr .fr
        AddLanguage en .en
        LanguagePriority fr en
        DirectoryIndex index
</Directory>

Here's my directory structure (you can test at http://langnego.no-ip.org ):

$ ls /var/www/htdocs/langnego/
index.html.fr     index.html.html   test.html.fr      test.html.html

I set my browser to prefer fr which I can tell from the custom log (see below)
the default directory returns the english page.  A request for test.html
returns a 404, and just when you thought +MultiViews wasn't working a request
for test returns the english text.html.html .  When I go to Google.com I get
their french page correctly...
 

64.81.200.243 - - [13/Jun/2005:15:44:30 -0400] "GET / HTTP/1.1" 200 17 "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050514 Firefox/1.0.4" "fr,en;q=0.5"
64.81.200.243 - - [13/Jun/2005:15:44:38 -0400] "GET /test.html HTTP/1.1" 404 215 "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050514 Firefox/1.0.4" "fr,en;q=0.5"
64.81.200.243 - - [13/Jun/2005:15:48:07 -0400] "GET /test HTTP/1.1" 200 17 "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050514 Firefox/1.0.4" "fr,en;q=0.5"


Thanks for any tips,

-- 
Marco



---------------------------------------------------------------------
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


[users@httpd] Re: still content negotiation problems

Posted by Marco Scoffier <ma...@metm.org>.
Hey Joshua,

Thanks for your response. 
Just replying to snips 'cause I figured it out.

On Mon, 13 Jun 2005 21:50:53 -0400, Joshua Slive wrote:

> Ouch. OpenBSD doesn't have mod_mime by default?  That's crazy.
> 

In fact OpenBSD does have mod_mime and mod_negotiation compiled in, I've
gotten so used to them ripping out things for security reasons, that
somewhere along in my trying to get this to work I came to this false
conclusion. I had forgotten about httpd -l .   Takes writing out the email
to find the problem... :)

It seems my extra LoadModule lines had been messing things up.  I removed
them and things work as expected.  

I've even added a some UTF-8 auto-negotiation 
and Japanese pages with 
 AddCharset UTF-8 .ja 
 AddCharset UTF-8 .fr

Nice !

> One thing missing from your config is a test.html.en.  This is necessary
> so that someone requesting "en,fr;q=0.5" will get the english page.  But
> the fact that that is missing doesn't explain why request test.html
> doesn't get you something.  That is a little curious.
> 

Thanks for the tip. I've symlinked page.html.html to page.html.en

Server is negotiating happily, and it's still too hot in NYC.

Thanks,

-- 
Marco



---------------------------------------------------------------------
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] still content negotiation problems

Posted by Joshua Slive <js...@gmail.com>.
On 6/13/05, Marco Scoffier <ma...@metm.org> wrote:
> I'm using OpenBSD's apache (which does not have many "standard" modules
> compiled):
> 
>  compiled mod_negotiation and mod_mime (which I am not 100% sure is needed):
>    cd /usr/scr/usr.sbin/httpd/modules/standard
>        apxs -i -a -c mod_negociation.c
>        apxs -i -a -c mod_mime.c

Ouch. OpenBSD doesn't have mod_mime by default?  That's crazy.

You might find it difficult to get help here with OpenBSD's version of
apache, since they don't really include apache, but rather a forked
version with some of their own patches and without patches from recent
apache versions.  I'm not sure how far it diverges from the official
version at the moment, but I believe it is significant and growing. 
Hence it is pretty much impossible for us to know if your problem is
in your configuration, in the apache source code, or in something that
openbsd did to apache.

> <Directory /var/www/htdocs/langnego/ >
>        Options +MultiViews
>        AddLanguage fr .fr
>        AddLanguage en .en
>        LanguagePriority fr en
>        DirectoryIndex index
> </Directory>
> 
> Here's my directory structure (you can test at http://langnego.no-ip.org ):
> 
> $ ls /var/www/htdocs/langnego/
> index.html.fr     index.html.html   test.html.fr      test.html.html
> 
> I set my browser to prefer fr which I can tell from the custom log (see below)
> the default directory returns the english page.  A request for test.html
> returns a 404, and just when you thought +MultiViews wasn't working a request
> for test returns the english text.html.html .  When I go to Google.com I get
> their french page correctly...
> 
> 
> 64.81.200.243 - - [13/Jun/2005:15:44:30 -0400] "GET / HTTP/1.1" 200 17 "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050514 Firefox/1.0.4" "fr,en;q=0.5"
> 64.81.200.243 - - [13/Jun/2005:15:44:38 -0400] "GET /test.html HTTP/1.1" 404 215 "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050514 Firefox/1.0.4" "fr,en;q=0.5"
> 64.81.200.243 - - [13/Jun/2005:15:48:07 -0400] "GET /test HTTP/1.1" 200 17 "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050514 Firefox/1.0.4" "fr,en;q=0.5"

It might be helpful to see what is in the error log.

One thing missing from your config is a test.html.en.  This is
necessary so that someone requesting "en,fr;q=0.5" will get the
english page.  But the fact that that is missing doesn't explain why
request test.html doesn't get you something.  That is a little
curious.

Joshua

---------------------------------------------------------------------
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