You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Zbigniew Szalbot <zs...@gmail.com> on 2008/02/01 17:18:43 UTC

[users@httpd] language-based redirection

Hello,

It is my first post to this list. I run Apache/2.0.61 on a FreeBSD 6.3
server. I would like to be able to set up a simple redirection because
I want to offer content in two languages.

I read about content negotiation in apache server and saw the example
files in the root www directory.

I just want to be able to do exactly the same thing as in the example
installation but I am not sure why it does not work in my case.

I do have
AddHandler type-map var
in my httpd.conf

There is index.html.var in the root folder.

It does have:

URI: index.html.po.iso8859-2
Content-language: pl
Content-type: text/html;charset=ISO-8859-2

defined in it. And yet while my browser language is PL, the website
server does not serve the index.html.po.iso8859-2.

What should I check to make it work?

Thank you!

Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Zbigniew Szalbot <zs...@gmail.com>.
2008/2/7, Nick Kew <ni...@webthing.com>:
> On Thu, 7 Feb 2008 10:33:44 +0100
> "Zbigniew Szalbot" <zs...@gmail.com> wrote:
>
>
> > Now I am putting in the index.html.po.iso8859-2 file the following
> > code: <META http-equiv="Content-Type" content="text/html;
> > charset=iso-8859-2"> <meta http-equiv="Location"
> > content="http://domain.tld/test/pl/index.php"> <meta
> > http-equiv="Status" content="301 Now where did I leave that URL">
>
> What's that supposed to do?

Right, I did read the documentation but I did not think I should be putting

Status: 301 Now where did I leave that URL
Location: http://xyz.abc.com/foo/bar.html
Content-type: text/html

at the beginning of an HTML file.

So, this does what I want so many thanks for your patience! BTW - the
docs are very helpful but for a person quite new to this area some of
the content may not be obvious. I know, I know - there is no shortcut
for learning. Thank you very much again!

-- 
Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Nick Kew <ni...@webthing.com>.
On Thu, 7 Feb 2008 10:33:44 +0100
"Zbigniew Szalbot" <zs...@gmail.com> wrote:


> Now I am putting in the index.html.po.iso8859-2 file the following
> code: <META http-equiv="Content-Type" content="text/html;
> charset=iso-8859-2"> <meta http-equiv="Location"
> content="http://domain.tld/test/pl/index.php"> <meta
> http-equiv="Status" content="301 Now where did I leave that URL">

What's that supposed to do?

You need mod_asis to be your handler for that file.  Then you
set the HTTP headers as in your previous message to the list
(in fact, CGI rules apply to mod_asis).

> $ cat /usr/local/etc/apache2/httpd.conf |grep "asis"

Alert .. useless use of cat awards (google it if you need to -
but not important).

> LoadModule asis_module libexec/apache2/mod_asis.so
> AddHandler send-as-is asis

That'll set mod_asis as handler for .asis files.

So you've got two things wrong:
 - mod_asis isn't set as handler for the file in question
 - the file contains <meta> crap instead of headers.

Since you probably don't want to activate mod_asis on the rest
of your server, why not rename your negotiated language files
from .html to .asis?

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

---------------------------------------------------------------------
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] language-based redirection

Posted by Joshua Slive <jo...@slive.ca>.
On Feb 7, 2008 4:33 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
> 2008/2/4, Nick Kew <ni...@webthing.com>:
> > On Mon, 4 Feb 2008 18:23:35 +0100
> > "Zbigniew Szalbot" <zs...@gmail.com> wrote:
> >
> > > Only this? Or should the header contain this:
> > >
> > > Status: 301 Now where did I leave that URL
> > > Location: http://xyz.abc.com/foo/bar.html
> > > Content-type: text/html
> >
> > Yep.  Get that up-and-running with mod_asis, then plug it in to
> > what you've got.
> >
> > You can return an HTML stub (like Apache's default 301 ErrorDocument)
> > just in case anyone ever looks at it.
>
> I did try to test it. So I have a test directory
> /test/ with Multiviews on
>
> in which there are the following files:
> index.html.var
> index.html.po.iso8859-2
>
> index.html.var has this:
> URI: index.html.po.iso8859-2
> Content-language: pl
> Content-type: text/html;charset=ISO-8859-2
>
> and it opens index.html.po.iso8859-2 file correctly. So far, so good.
>
> Now I am putting in the index.html.po.iso8859-2 file the following code:
>   <META http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
> <meta http-equiv="Location" content="http://domain.tld/test/pl/index.php">
> <meta http-equiv="Status" content="301 Now where did I leave that URL">
>
> But this has no effect (i.e. no redirection). The browser still
> displays http://domain.tld/test instead of http://domain.tld/test/pl/
>
> $ cat /usr/local/etc/apache2/httpd.conf |grep "asis"
> LoadModule asis_module libexec/apache2/mod_asis.so
> AddHandler send-as-is asis
>
> Error log says nothing. Access log has this:
> 192.168.16.1 - - [07/Feb/2008:10:31:54 +0100] "GET /test/ HTTP/1.1" 304 -
> 192.168.16.1 - - [07/Feb/2008:10:31:54 +0100] "GET /test/ HTTP/1.1" 304 -
> 192.168.16.1 - - [07/Feb/2008:10:32:02 +0100] "GET /test/ HTTP/1.1" 200 1535
> 192.168.16.1 - - [07/Feb/2008:10:32:16 +0100] "GET /test/ HTTP/1.1" 200 1535
>
> Many thanks for pointers how to make it work!

You are moving farther away from the solution rather than closer. Your
main problem seems to be not reading the docs. The docs for mod_asis
have a specific example of what should be in an .asis file to generate
a redirect. Start from there.

Then your second problem is that your files are not actually being
processed by mod_asis, because they aren't using the asis extension.
You'll want to name them something like index.asis.po.iso8859-2

(Also, if you go with mod_rewrite instead, using the RewriteLog to
help you debug.)

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


Re: [users@httpd] language-based redirection

Posted by Zbigniew Szalbot <zs...@gmail.com>.
2008/2/4, Nick Kew <ni...@webthing.com>:
> On Mon, 4 Feb 2008 18:23:35 +0100
> "Zbigniew Szalbot" <zs...@gmail.com> wrote:
>
> > Only this? Or should the header contain this:
> >
> > Status: 301 Now where did I leave that URL
> > Location: http://xyz.abc.com/foo/bar.html
> > Content-type: text/html
>
> Yep.  Get that up-and-running with mod_asis, then plug it in to
> what you've got.
>
> You can return an HTML stub (like Apache's default 301 ErrorDocument)
> just in case anyone ever looks at it.

I did try to test it. So I have a test directory
/test/ with Multiviews on

in which there are the following files:
index.html.var
index.html.po.iso8859-2

index.html.var has this:
URI: index.html.po.iso8859-2
Content-language: pl
Content-type: text/html;charset=ISO-8859-2

and it opens index.html.po.iso8859-2 file correctly. So far, so good.

Now I am putting in the index.html.po.iso8859-2 file the following code:
  <META http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<meta http-equiv="Location" content="http://domain.tld/test/pl/index.php">
<meta http-equiv="Status" content="301 Now where did I leave that URL">

But this has no effect (i.e. no redirection). The browser still
displays http://domain.tld/test instead of http://domain.tld/test/pl/

$ cat /usr/local/etc/apache2/httpd.conf |grep "asis"
LoadModule asis_module libexec/apache2/mod_asis.so
AddHandler send-as-is asis

Error log says nothing. Access log has this:
192.168.16.1 - - [07/Feb/2008:10:31:54 +0100] "GET /test/ HTTP/1.1" 304 -
192.168.16.1 - - [07/Feb/2008:10:31:54 +0100] "GET /test/ HTTP/1.1" 304 -
192.168.16.1 - - [07/Feb/2008:10:32:02 +0100] "GET /test/ HTTP/1.1" 200 1535
192.168.16.1 - - [07/Feb/2008:10:32:16 +0100] "GET /test/ HTTP/1.1" 200 1535

Many thanks for pointers how to make it work!

-- 
Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 4 Feb 2008 18:23:35 +0100
"Zbigniew Szalbot" <zs...@gmail.com> wrote:

> Only this? Or should the header contain this:
> 
> Status: 301 Now where did I leave that URL
> Location: http://xyz.abc.com/foo/bar.html
> Content-type: text/html

Yep.  Get that up-and-running with mod_asis, then plug it in to
what you've got.

You can return an HTML stub (like Apache's default 301 ErrorDocument)
just in case anyone ever looks at it.


-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

---------------------------------------------------------------------
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] language-based redirection

Posted by Zbigniew Szalbot <zs...@gmail.com>.
Hello,

2008/2/4, Nick Kew <ni...@webthing.com>:
> On Mon, 4 Feb 2008 11:30:59 -0500
> "Joshua Slive" <jo...@slive.ca> wrote:
>
> > On Feb 4, 2008 1:43 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
> >
> > > The thing is that in order to provide blogs in two languages I
> > > cannot install one blog and make it display in two languages. It
> > > needs to be two blogs. Hence, they need to be in two separate
> > > directories. But I am happy to do the langauge recognition in a
> > > common directory and then redirect to a specific blog. Thank you!
> >
> > If you want the full language negotiation done by apache (checking
> > priorities, etc), then your meta-refresh hack may indeed be the best
> > idea.
>
> Meta refresh is never, ever, acceptable.  It buggers up browsers.
>
> Looking up the thread, an altogether better solution would be
> to use mod_asis to generated external redirects from the
> content-negotiated indexes.
>
> You should still of course enable users to override that choice.
> For example a visitor may be fluent in both languages, or may be
> traveling, and using a hotel or library's browser configured with
> different preferences to their own.

Thanks Nick. I did have a loot at:
http://webauth.stanford.edu/manual/mod/mod_asis.html

Now, what I do not understand is what should the HTML file contain.

<html>
<head>
<title>Lame excuses'R'us</title>
</head>
<body>
<h1>Fred's exceptionally wonderful page has moved to
<a href="http://xyz.abc.com/foo/bar.html">Joe's</a> site.
</h1>
</body>
</html>

Only this? Or should the header contain this:

Status: 301 Now where did I leave that URL
Location: http://xyz.abc.com/foo/bar.html
Content-type: text/html

I do not really want to show people a page moved message as nothing
has moved. I just want to redirect to two different subdirectories
based on browser's language.

Thanks!

Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 4 Feb 2008 11:30:59 -0500
"Joshua Slive" <jo...@slive.ca> wrote:

> On Feb 4, 2008 1:43 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
> 
> > The thing is that in order to provide blogs in two languages I
> > cannot install one blog and make it display in two languages. It
> > needs to be two blogs. Hence, they need to be in two separate
> > directories. But I am happy to do the langauge recognition in a
> > common directory and then redirect to a specific blog. Thank you!
> 
> If you want the full language negotiation done by apache (checking
> priorities, etc), then your meta-refresh hack may indeed be the best
> idea.

Meta refresh is never, ever, acceptable.  It buggers up browsers.

Looking up the thread, an altogether better solution would be
to use mod_asis to generated external redirects from the
content-negotiated indexes.

You should still of course enable users to override that choice.
For example a visitor may be fluent in both languages, or may be
traveling, and using a hotel or library's browser configured with
different preferences to their own.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

---------------------------------------------------------------------
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] language-based redirection

Posted by Joshua Slive <jo...@slive.ca>.
On Feb 7, 2008 5:02 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
> 2008/2/4, Joshua Slive <jo...@slive.ca>:
>
> > On Feb 4, 2008 1:43 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
> >
> > > The thing is that in order to provide blogs in two languages I cannot
> > > install one blog and make it display in two languages. It needs to be
> > > two blogs. Hence, they need to be in two separate directories. But I
> > > am happy to do the langauge recognition in a common directory and then
> > > redirect to a specific blog. Thank you!
> >
> > If you want the full language negotiation done by apache (checking
> > priorities, etc), then your meta-refresh hack may indeed be the best
> > idea. (I almost never suggest that, since it is much better to do
> > proper HTTP redirects. But this is a special case. I don't know a
> > clean way to get mod_negotiation to generate an external redirect.)
> >
> > If you just want to do a simple scan of the browser's accept-language,
> > you can use mod_rewrite:
> >
> > RewriteCond %{HTTP:Accept-Language} ^pl$
> > RewriteRule ^/blog/?$ http://yoursite.example.com/blog/pl/ [R,L]
> > RewriteRule ^/blog/?$ http://yoursite.example.com/blog/en/ [R]
>
> One more question here... the above does not work. I even pointed it
> to another file in the current directory (blog)
>
> RewriteRule ^/blog/?$ http://yoursite.example.com/blog/file.html [R,L]
>
> but it would not open it either.
>
> error log says nothing.

If you are going to use mod_rewrite, you unfortunately are going to
need to dig into its docs to understand what you are doing. It's not
fun, but it is necessary.

Just to get you started, when using mod_rewrite in an .htaccess file,
references become relative, so you need to remove the leading / at
least. See the RewriteBase directive.

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


Re: [users@httpd] language-based redirection

Posted by Zbigniew Szalbot <zs...@gmail.com>.
2008/2/4, Joshua Slive <jo...@slive.ca>:
> On Feb 4, 2008 1:43 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
>
> > The thing is that in order to provide blogs in two languages I cannot
> > install one blog and make it display in two languages. It needs to be
> > two blogs. Hence, they need to be in two separate directories. But I
> > am happy to do the langauge recognition in a common directory and then
> > redirect to a specific blog. Thank you!
>
> If you want the full language negotiation done by apache (checking
> priorities, etc), then your meta-refresh hack may indeed be the best
> idea. (I almost never suggest that, since it is much better to do
> proper HTTP redirects. But this is a special case. I don't know a
> clean way to get mod_negotiation to generate an external redirect.)
>
> If you just want to do a simple scan of the browser's accept-language,
> you can use mod_rewrite:
>
> RewriteCond %{HTTP:Accept-Language} ^pl$
> RewriteRule ^/blog/?$ http://yoursite.example.com/blog/pl/ [R,L]
> RewriteRule ^/blog/?$ http://yoursite.example.com/blog/en/ [R]

One more question here... the above does not work. I even pointed it
to another file in the current directory (blog)

RewriteRule ^/blog/?$ http://yoursite.example.com/blog/file.html [R,L]

but it would not open it either.

error log says nothing.

Thanks!

-- 
Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Zbigniew Szalbot <zs...@gmail.com>.
Hello,

2008/2/4, Joshua Slive <jo...@slive.ca>:
> On Feb 4, 2008 1:43 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
>
> > The thing is that in order to provide blogs in two languages I cannot
> > install one blog and make it display in two languages. It needs to be
> > two blogs. Hence, they need to be in two separate directories. But I
> > am happy to do the langauge recognition in a common directory and then
> > redirect to a specific blog. Thank you!
>
> If you want the full language negotiation done by apache (checking
> priorities, etc), then your meta-refresh hack may indeed be the best
> idea. (I almost never suggest that, since it is much better to do
> proper HTTP redirects. But this is a special case. I don't know a
> clean way to get mod_negotiation to generate an external redirect.)
>
> If you just want to do a simple scan of the browser's accept-language,
> you can use mod_rewrite:
>
> RewriteCond %{HTTP:Accept-Language} ^pl$
> RewriteRule ^/blog/?$ http://yoursite.example.com/blog/pl/ [R,L]
> RewriteRule ^/blog/?$ http://yoursite.example.com/blog/en/ [R]

I will probably stick with meta-refresh as the above does not seem to
work (I put the directive in a .htaccess file).

Anyway, thank you very, very much for your contribution!

Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Joshua Slive <jo...@slive.ca>.
On Feb 4, 2008 1:43 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:

> The thing is that in order to provide blogs in two languages I cannot
> install one blog and make it display in two languages. It needs to be
> two blogs. Hence, they need to be in two separate directories. But I
> am happy to do the langauge recognition in a common directory and then
> redirect to a specific blog. Thank you!

If you want the full language negotiation done by apache (checking
priorities, etc), then your meta-refresh hack may indeed be the best
idea. (I almost never suggest that, since it is much better to do
proper HTTP redirects. But this is a special case. I don't know a
clean way to get mod_negotiation to generate an external redirect.)

If you just want to do a simple scan of the browser's accept-language,
you can use mod_rewrite:

RewriteCond %{HTTP:Accept-Language} ^pl$
RewriteRule ^/blog/?$ http://yoursite.example.com/blog/pl/ [R,L]
RewriteRule ^/blog/?$ http://yoursite.example.com/blog/en/ [R]

---------------------------------------------------------------------
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] language-based redirection

Posted by Zbigniew Szalbot <zs...@gmail.com>.
Hello again,

2008/2/4, Joshua Slive <jo...@slive.ca>:
> On Feb 1, 2008 1:54 PM, Zbigniew Szalbot <zs...@gmail.com> wrote:
>
> > Thank you very much Joshua! I haven't realized I need to call
> > index.html.var. I switched to Mutilviews as it is much better indeed.
> >
> > I have one more question. Now that it works, I have the following
> > directory structure for a virtual domain
> >
> > DocumentRoot /usr/local/www/blog/
> >
> > blog/
> > this is where index.html.en and index.html.po are
> >
> > I would like index.html.po redirect to
> > blog/pl/
> >
> > and index.html.en redirect to
> > blog/en/
> >
> > I realize I can put refresh in the html files to automatically
> > redirect to blog/pl/ or blog/en/
> > Something like http-equiv="REFRESH" content="0;URL=http://domain.tld/blog/en/"
> >
> > But is there a better way of doing it?
>
> What exactly are you trying to accomplish? If you do redirects like
> that, you are going outside the multiviews world.

Right, it is true.

>
> It can be done with mod_rewrite, but if you better explained why you
> want to do it, we might have better answers.

The thing is that in order to provide blogs in two languages I cannot
install one blog and make it display in two languages. It needs to be
two blogs. Hence, they need to be in two separate directories. But I
am happy to do the langauge recognition in a common directory and then
redirect to a specific blog. Thank you!

Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Joshua Slive <jo...@slive.ca>.
On Feb 1, 2008 1:54 PM, Zbigniew Szalbot <zs...@gmail.com> wrote:

> Thank you very much Joshua! I haven't realized I need to call
> index.html.var. I switched to Mutilviews as it is much better indeed.
>
> I have one more question. Now that it works, I have the following
> directory structure for a virtual domain
>
> DocumentRoot /usr/local/www/blog/
>
> blog/
> this is where index.html.en and index.html.po are
>
> I would like index.html.po redirect to
> blog/pl/
>
> and index.html.en redirect to
> blog/en/
>
> I realize I can put refresh in the html files to automatically
> redirect to blog/pl/ or blog/en/
> Something like http-equiv="REFRESH" content="0;URL=http://domain.tld/blog/en/"
>
> But is there a better way of doing it?

What exactly are you trying to accomplish? If you do redirects like
that, you are going outside the multiviews world.

It can be done with mod_rewrite, but if you better explained why you
want to do it, we might have better answers.

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


Re: [users@httpd] language-based redirection

Posted by Zbigniew Szalbot <zs...@gmail.com>.
Hello,

2008/2/1, Joshua Slive <jo...@slive.ca>:
> On Feb 1, 2008 11:18 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
> > Hello,
> >
> > It is my first post to this list. I run Apache/2.0.61 on a FreeBSD 6.3
> > server. I would like to be able to set up a simple redirection because
> > I want to offer content in two languages.
> >
> > I read about content negotiation in apache server and saw the example
> > files in the root www directory.
> >
> > I just want to be able to do exactly the same thing as in the example
> > installation but I am not sure why it does not work in my case.
> >
> > I do have
> > AddHandler type-map var
> > in my httpd.conf
> >
> > There is index.html.var in the root folder.
> >
> > It does have:
> >
> > URI: index.html.po.iso8859-2
> > Content-language: pl
> > Content-type: text/html;charset=ISO-8859-2
> >
> > defined in it. And yet while my browser language is PL, the website
> > server does not serve the index.html.po.iso8859-2.
> >
> > What should I check to make it work?
>
> What are you requesting in the browser? You'd need to request
> index.html.var to make that work. You might prefer to use multiviews,
> where you don't need to explicitly specify all the variants. But in
> either case, you need to name all your variants with the proper
> language codes. So if you have an en and pl version, you need
> index.html.en
> and
> index.html.po...
> Then requesting index.html with multiviews on will trigger language negotiation.

Thank you very much Joshua! I haven't realized I need to call
index.html.var. I switched to Mutilviews as it is much better indeed.

I have one more question. Now that it works, I have the following
directory structure for a virtual domain

DocumentRoot /usr/local/www/blog/

blog/
this is where index.html.en and index.html.po are

I would like index.html.po redirect to
blog/pl/

and index.html.en redirect to
blog/en/

I realize I can put refresh in the html files to automatically
redirect to blog/pl/ or blog/en/
Something like http-equiv="REFRESH" content="0;URL=http://domain.tld/blog/en/"

But is there a better way of doing it?

Thank you again!

Zbigniew Szalbot

---------------------------------------------------------------------
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] language-based redirection

Posted by Joshua Slive <jo...@slive.ca>.
On Feb 1, 2008 11:18 AM, Zbigniew Szalbot <zs...@gmail.com> wrote:
> Hello,
>
> It is my first post to this list. I run Apache/2.0.61 on a FreeBSD 6.3
> server. I would like to be able to set up a simple redirection because
> I want to offer content in two languages.
>
> I read about content negotiation in apache server and saw the example
> files in the root www directory.
>
> I just want to be able to do exactly the same thing as in the example
> installation but I am not sure why it does not work in my case.
>
> I do have
> AddHandler type-map var
> in my httpd.conf
>
> There is index.html.var in the root folder.
>
> It does have:
>
> URI: index.html.po.iso8859-2
> Content-language: pl
> Content-type: text/html;charset=ISO-8859-2
>
> defined in it. And yet while my browser language is PL, the website
> server does not serve the index.html.po.iso8859-2.
>
> What should I check to make it work?

What are you requesting in the browser? You'd need to request
index.html.var to make that work. You might prefer to use multiviews,
where you don't need to explicitly specify all the variants. But in
either case, you need to name all your variants with the proper
language codes. So if you have an en and pl version, you need
index.html.en
and
index.html.po...
Then requesting index.html with multiviews on will trigger language negotiation.

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