How to select content type from HTTP Accept header in PHP -


I am trying to create a standard consistent website framework that creates XHTML1 as the text application / XHTML + XML or HTML 4.01 / Html Depending on browser support, currently it appears only for "App / XHTML + XML" anywhere in the "Header / Acceptable Header, and uses it if it exists, but it is not flexible - Lesson In addition, higher scores can be in html / html, besides this, it will be more complex when other formats (WAP, SVG, Explosives etc.) will be added. So, does anyone know that by server Do you know about a tried and tested piece of PHP code to get the best support of the sorted list based on client or client score given from the given string array?

You can take advantage of this way when you want to deliver content type (E, G, "I really want to apply the application / XHTML + XML Modules including your own preferences for the client The original solution of the whole range of offers can be used very much like ".) Original solution:

  • addHandler type-map .var with an .htaccess file Create content as
  • Make a file foo.var
     URI: Foo URI: af.fp / html content-type: text / html; Qs = 0.7 
    URI: foo.php / xhtml Content-Type: App / XHTML + XML; Qs = 0.8
    as the content
  •  & lt ;? Create a file foo.php with php 'selected type:', substr ($ _ SERVER ['pathheff'], 1); 
  • Request

For this, you need to enable mod_negotiation, the privilege for the appropriate AllowOverride AddHandler and $ _SERVER ['PATH_INFO']. By sending your Firefox "Accept: Text / HTML, App / XHTML + XML, Application / XML; Q = 0.9, / ; Q = 0.8" and example. View the result "Selected Type: XHTML".
You can use other "tweaks" to get rid of PATHIOFOs or to request the Foo .var , but the basic concept is: mod_negotiation redirect the request to your php script So that the script could "read" selected content-type.

So, anyone has to know about a tried and tested piece of PHP code to select
; This is not a pure PHP solution, but I can say that mod_negotiation has been tested and tested ;-)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -