You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Isenberg, Holger" <is...@e-spirit.com> on 2010/10/12 17:09:10 UTC

[users@httpd] Using mod_negotiation with RewriteMap for language based redirect?

Hi,

to provide virtual URLs which are redirected by content negotiation based on the Browsers accept-language header, I use PHP files as follows for example for http://hostname.domain/shorturl which is redirected to http://hostname.domain/de/path/to/file.html for German readers, http://hostname.domain/en/path/to/file.html for English and likewise for 2 other languages.

As I don't like to use PHP on that server at all, other solutions are preferred. Using RewriteMap failed as RewriteMap seems to combine with mod_negotiation or MultiViews only on the destination path (de/path/to/file.html) of the rewrite map not the key (/shorturl).

And to rebuild the internal functions of MultiViews by a list of RewriteCond isn't possible if you want evalution of more elaborated Accept-Language headers like "de-de, de;q=0.75, en-us;q=0.50, en;q=0.25" which MultiViews and mod_negotation eat easily.


file shorturl.php.en:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Status: 301 Moved Permanently");
header("Location:http://" . $_SERVER["HTTP_HOST"] . "/en/path/to/file.html");
header("Connection:close");
exit;
?>


file product.php.de:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Status: 301 Moved Permanently");
header("Location:http://" . $_SERVER["HTTP_HOST"] . "/de/path/to/file.html");
header("Connection:close");
exit;
?>


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