Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    21
    Thanks
    3
    Thanked 2 Times in 2 Posts

    .htaccess - why env=xxx in header directive doesn't work?

    I am trying to be nice and to only send certain headers to MSIE:

    Code:
    SetEnvIfNoCase User-Agent .*MSIE.* is_msie
    Header set X-UA-Compatible "IE8" env=is_msie
    Header set imagetoolbar "no" env=is_msie
    But I am getting 500 Internal Server Error which goes away when I comment out those two Header lines or remove "env=is_msie" part.

    According to the docs this should work. Modules mod_setenvif and mod_headers are loaded. Any ideas why it doesn't work?

    Server is Apache/2.2.10 (Unix).
    Last edited by levicki; 03-29-2009 at 10:04 PM.

  • #2
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    That looks ok [and worked for me].
    Are you sure mod_headers is loaded? [if it really is, what does the error log say?]

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    21
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by freedom_razor View Post
    Are you sure mod_headers is loaded?
    I am because I can set headers (I see them coming to the browser), it is the env= part that breaks things.

    Quote Originally Posted by freedom_razor View Post
    [if it really is, what does the error log say?]
    That I cannot say, I don't have access to the error log.

    I thought this might be some known issue or my personal mistake, it seems I will have to take it up with my hosting company support.

  • #4
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    Tried using a different var name?

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    21
    Thanks
    3
    Thanked 2 Times in 2 Posts
    I did, sorry I made a mistake, server is not Apache 2.x it is Apache 1.3.x -- I don't have a clue how I mixed that up. It seems that 1.3.x doesn't support it.

  • #6
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    You can detect browser with RewriteCond, and then send files [if its IE] appending headers with PHP.

    For example, in .htaccess:
    Code:
    RewriteCond  %{HTTP_USER_AGENT} .*MSIE.*
    RewriteRule (.+\.html)$ /head.php?filename=$1
    and then in head.php:
    Code:
    <?php
    $file=$_GET['filename'];
    header('X-UA-Compatible: IE8');
    header('imagetoolbar: no');
    include($file);
    ?>
    Or just do it all with PHP, though that would mean adding a browser detection/headers to all your files. [might be better in case of conflics rules in .htaccess]
    Last edited by freedom_razor; 04-01-2009 at 08:42 PM.

  • Users who have thanked freedom_razor for this post:

    levicki (04-03-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •