htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Issue with mod_rewrite/conneg interaction
PostPosted: 01 Sep 2008 15:39 
Offline

Joined: 01 Sep 2008 15:27
Posts: 2
Hi,
I am trying to do this:
Have bar.html and bar.html.ja on disk
to ease browsing on file system, I want to keep bar.html (and not use bar.html.html) and I need to do conneg between bar.html (in english) and bar.html.ja (in japanese).
Here is what I tried (with no luck :) )
Code:
MultiviewsMatch Handlers

RewriteEngine On
RewriteBase /foo

RewriteCond %{ENV:foobar} !^Yes$
RewriteRule bar.html$ bar-html.var [L]

RewriteRule bar.html.en$ bar.html [E=foobar:Yes]


bar-html.var contains this:
Code:
URI: bar-html

URI: bar.html.ja
Content-Language: ja

URI: bar.html.en
Content-Language: en

When Accept-Language: contains ja, it works and gives me the japanese version
So, the first rewrite
Code:
RewriteRule bar.html$ bar-html.var [L]
works, then the .var kicks in
returns bar.html.ja, all fine.
When it is not set, I see that it reaches the limit of redirects.
So... first rewrite works, then with the .var bar.html.en is requested, then... the rewrite setting the 'foobar' variable does not work. adding a [L] didn't help either.
Where is the bug :) ?
(I am using Apache 2.2.9)
Cheers,


Top
 Profile  
 
 Post subject: Re: Issue with mod_rewrite/conneg interaction
PostPosted: 12 Sep 2008 17:32 
Offline

Joined: 30 Oct 2006 19:55
Posts: 99
joeluser - wow that is really complicated.. how about doing something much simpler?

Code:
HTACCESS: /.htaccess
TYPE-MAP: /bar.html
ENGLISH:  /bar.html.en
JAPANESE: /bar.html.ja


/bar.html
Code:
URI: bar.html.en
Content-Language: en
Content-type: text/html; charset=UTF-8

URI: bar.html.ja
Content-Language: ja
Content-type: text/html; charset=EUC-JP



/.htaccess
Code:
Options FollowSymLinks Indexes

AddHandler type-map var

<Files *.html>
SetHandler type-map
</Files>

# List the languages in decreasing order of preference.
LanguagePriority en ja

ForceLanguagePriority Prefer Fallback

RewriteEngine On
RewriteBase /

#
# This rule changes the language when ?lang=ja is appended to a request..
# Good for debugging
#
RewriteCond %{QUERY_STRING} lang=(en|ja) [NC]
RewriteRule .* - [E=prefer-language:%1,S=1,L]
RewriteCond %{HTTP:Accept-Language} ^.*(ja|en)[^a-z]? [NC]
RewriteRule .* - [E=prefer-language:%1,L]

RequestHeader set Accept-Language "%{prefer-language}e" env=prefer-language


Top
 Profile  
 
 Post subject: Re: Issue with mod_rewrite/conneg interaction
PostPosted: 17 Sep 2008 14:20 
Offline

Joined: 01 Sep 2008 15:27
Posts: 2
That would be ideal, but this solution would remove the possibility of browsing on the file system directly for the default language.
But your proposal led to the solution: Use
Code:
RequestHeader set X-Loop-Check "Yes"
and
Code:
RewriteCond %{HTTP:X-Loop-Check} ^Yes$
instead of using the ENV: stuff.

Yes it looks a bit complex, but now it works :)
Thanks,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


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

Search for:
Powered by phpBB