#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0

    Set language in http header


    Hi,
    trying to follow w3c guidelines for mobiles I get this warning:
    The mobile HTTP delivery chains usually involve more intermediaries than typical desktop chains (e.g. mobile operator gateways).The intermediaries will stick to the HTTP level, and won't dig in the content of the page to check for meta http-equiv elements.
    For the value not to be ignored, a matching HTTP header should be defined in the HTTP response.
    http-equiv=content-language

    So I am trying to search for how to do it in htaccess.
    I have 3 languages, they are not in subdomains but they are in diferent directories, I read somthing about default languages but can find out how to set it up for diferent folders.
    English is the root, then spanish is in directory /espanol/ and swedish in /svenska/, also my host use LiteSpeed so lets hope it works.
    Thanks in advance,
    Helena
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1100
    I believe mod_headers should do the trick.
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    Thanks, but sorry, dont understand what to do, as it does not say anything about languages.
    I only want to set language for each directory in the http header.
  6. #4
  7. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,129
    Rep Power
    4304
    To set it to English, you put this in your .htaccess file:
    Code:
    Header set Content-Language "en"
    To conditionally set it to other languages within the .htaccess file, you'll need to use mod_rewrite or mod_setenvif to set an environment variable (here's an example of that).

    Apparently to do this in Litespeed, you'll need to use the mod_rewrite variant.
    https://store.litespeedtech.com/stor...ayarticle&id=6
    http://www.litespeedtech.com/docs/we...onfig/rewrite/
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    Originally Posted by Kravvitz
    To set it to English, you put this in your .htaccess file:
    Code:
    Header set Content-Language "en"
    To conditionally set it to other languages within the .htaccess file, you'll need to use mod_rewrite or mod_setenvif to set an environment variable (here's an example of that).

    Apparently to do this in Litespeed, you'll need to use the mod_rewrite variant.
    https://store.litespeedtech.com/stor...ayarticle&id=6
    http://www.litespeedtech.com/docs/we...onfig/rewrite/
    Thanks,

    I not sure I ge
    ot it, as in that link finally I did not need to specify any directory so it worked.
    I just had a similar problem, I added to the roothtaccess (as my english files are in root) a cache for 2 hours for php, in my intranet (a subfolder) in another htaccess I had for php no cache must revalidate. And still it cached my php files in the intranet.


    I am very bad of understanding those things,
    normal apache, would be
    1.Header set Content-Language "en"
    2 something like:
    SetEnvIf Request_URI "\espanol\$" Header set Content-Language "es"
    3SetEnvIf Request_URI "\svenska\$" Header set Content-Language "se"

    But need moodrewrite as is Litespeed.
    would be similar
    1. Header set Content-Language "en"
    2 RewriteRule (*)(\espanol\) Header set Content-Language "es"
    3 RewriteRule (*)(\svenska\) Header set Content-Language "se"

    I know this is absolutely incorrect lol
  10. #6
  11. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,129
    Rep Power
    4304
    Oops. Sorry. I thought I had shown an additional code example in the other thread I linked to which would have shown how to use the environment variables.

    Each directive needs to go on its own line. Putting two on a line like that won't work.

    Try this:
    Code:
    RewriteEngine On
    RewriteRule / - [env=contentLang:en]
    RewriteRule /espanol/? - [env=contentLang:es]
    RewriteRule /svenska/? - [env=contentLang:se]
    
    Header set Content-Language %{contentLang}e
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    Originally Posted by Kravvitz
    Oops. Sorry. I thought I had shown an additional code example in the other thread I linked to which would have shown how to use the environment variables.

    Each directive needs to go on its own line. Putting two on a line like that won't work.

    Try this:
    Code:
    RewriteEngine On
    RewriteRule / - [env=contentLang:en]
    RewriteRule /espanol/? - [env=contentLang:es]
    RewriteRule /svenska/? - [env=contentLang:se]
    
    Header set Content-Language %{contentLang}e
    Thanks,
    but that did not work, I added it just after this:
    AddType application/x-httpd-php5 .htm .html
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^marbellasunrentals\.com
    RewriteRule (.*) http://www.marbellasunrentals.com/$1 [R=301,L]
    Helen
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    Originally Posted by Kravvitz
    Oops. Sorry. I thought I had shown an additional code example in the other thread I linked to which would have shown how to use the environment variables.

    Each directive needs to go on its own line. Putting two on a line like that won't work.

    Try this:
    Code:
    RewriteEngine On
    RewriteRule / - [env=contentLang:en]
    RewriteRule /espanol/? - [env=contentLang:es]
    RewriteRule /svenska/? - [env=contentLang:se]
    
    Header set Content-Language %{contentLang}e
    Reopening this post as host upgrade Lite Speed version,
    I tried your code and added it like this:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^marbellasunrentals\.com
    RewriteRule (.*) http://www.marbellasunrentals.com/$1 [R=301,L]
    RewriteRule / - [env=contentLang:en]
    RewriteRule /espanol/? - [env=contentLang:es]
    RewriteRule /svenska/? - [env=contentLang:se]
    Header set Content-Language %{contentLang}e
    And got in the header this:
    Content-Language %{contentLang}e

    It looks strange to me, suppose its not correct,
    anything I did wrong?
    Thanks
  16. #9
  17. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,129
    Rep Power
    4304
    Apparently Lite Speed doesn't support using environment variables like that.

    Here's the other way to write it that might work on Lite Speed.
    Code:
    RewriteEngine On
    RewriteRule /espanol/? - [env=contentLangES:true]
    RewriteRule /svenska/? - [env=contentLangSE:true]
    
    Header set Content-Language en
    Header set Content-Language es env=contentLangES
    Header set Content-Language se env=contentLangSE
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    Thanks, not sure what this mean but
    in the header of the html file I do not get anything,
    but in the .css, .gif files etc I get:
    Content-Language en, es, se
    in all 3 languages

IMN logo majestic logo threadwatch logo seochat tools logo