Serving XHTML as HTML to MSIE browsers in NginX

elliottcable nginx-forum at nginx.us
Mon Apr 6 08:35:25 MSD 2009


I'm trying to configure my server to serve XHTML files to MSIE browsers as text/html.

Here's the three things I've tried; all of them yell at me about a syntax error, so I can't launch my server:


location ~* \.(xhtml|xhtm) {
  if ($http_user_agent ~* MSIE) {
    types { }
    default_type text/html
  }
}



if ($http_user_agent ~* MSIE) {
  location ~* \.(xhtml|xhtm) {
    types { }
    default_type text/html
  }
}



includes.conf:
if ($http_user_agent ~* MSIE) {
  include /srv/conf/nginx/msie.conf;
}

msie.conf:
location ~* \.(xhtml|xhtm) {
  types { }
  default_type text/html
}


I've tried everything I can think of at this point. I can't find documentation on what's allowed inside of an if() clause; it just keeps throwing syntax errors at me.

I've also tried googling for other examples of the if() clause; all the examples I could find only ever used it in this form:

if (-f …)


Is that the only thing the if() clause is useful for?

I've got some time sensitive content that *needs* to get online, and moreover, be visible to MSIE users (that's a first for me). I don't have the time to re-write my CMS to serve HTML to MSIE either; this should really be done from the server side anyway. Any help would be much appreciated!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,839,839#msg-839






More information about the nginx mailing list