<-
Apache > HTTP Server > Documentation > Version 2.4

�) (Content Negotiation)

¹® 5 � 5±Ù ó°� �) ¹® � Âü� .

9 HTTP/1.1 � ±â �) (content negotiation) ' �) media type, � ¹® ' � � �<0 � °ø � � � � � º¸ º¸� �<0 2 �< 2¸® ±â�

±âº»� ÄÄ � mod_negotiation ¸ð �) ±â� °ø

Âü

top

�) /a>

� ¤¸� �' � � ¤¸� �4 ¤¸� media type � ¸ð � ¤¸� � � � �' ¹æ �) � ¸ñ � � º¸,ÁÖ� � ¬´ ±×� �� � � �% � �<0 � 2 � � ±×� � º¸ º¸ô±â¹� �% � � �<0 �% ½´ , ±×� ¤¸� � º¸ º¸�� � �<0 2 � � ±×� ±â � � � ½´ � ̤¸é �<0 � � � º¸�

Accept-Language: fr

� ±â � �4 � � °æ0 � °ï

� º¹! 2 � �<0 � ½´ � � '�, ½´ � �, � media type � '�, � � º¸� HTML, ¤¸� media type º¸� GIF JPEG � � �

Accept-Language: fr; q=1.0, en; q=0.5
Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1

9 HTTP/1.1 � '� ÁÖ (server driven)' �) ' 9 Accept, Accept-Language, Accept-Charset, Accept-Encoding 2 � � ¸ð ' , 9 RFC 2295 RFC 2296 � �) '�$� transparent)' 2 � ' ±×� RFC '±â (feature negotiation)' ''

(resource) (RFC 2396) URI� ±¸ � Á¸, 9 � � � (representations) °ø ' media type, ¹® ' � � �' ¹ê �� � � (� � � ¤¸� �% � (negotiable) ö¸£¸�, � � �(variant)�� �% � "�� �(dimension)

top

9

±â � � � º¸ � �' ¹æ $ � º¸ �

type-map �) �/a>

type map type-map� ��� °°� (� � 9 � � � MIME type application/x-type-map ¹® ±â� �) ¤¸� � type-map ��� � � � � �< � � � � � "

AddHandler type-map .var

Type map � �� � � � �, � � �� � �� � HTTP � $� ±¸1 � �� ��� �$� ±¸ �� �$ �) (� � � �, � ¹« '�) � �� °ø �< �'� �)< map � � º¸ �4 � map � � foo.var�, foo� �

URI: foo

URI: foo.en.html
Content-type: text/html
Content-language: en

URI: foo.fr.de.html
Content-type: text/html;charset=iso-8859-2
Content-language: fr, de

typemap � � � º¸ � Multiviews� �) � , � � �' ÁÖ � � ¤¸� ' °Â©¸�, � � � (JPEG, GIF, ASCII-art �� ) media type "qs" �� '(source quality)

URI: foo

URI: foo.jpeg
Content-type: image/jpeg; qs=0.8

URI: foo.gif
Content-type: image/gif; qs=0.5

URI: foo.txt
Content-type: text/plain; qs=0.01

qs � 0.000 1.000 �4 qs � 0.000 � ' ÁÖ 'qs' � � 1.0� Ãë qs � ��48 � �å°� �� ¤¸� ¼ä°ú �� � � ''' � � � � �� °æ JPEG � ASCII ¼º�� ' �' ±×� ASCII art¤¸� ASCII JPEG º¸ ' �' ±×� � � � qs � � � � ¤¸�

' ¸ð � ¸ñ mod_negotation typemap ¹® � Âü

Multiviews

MultiViews ¸® �4 �, apache2.conf , , � � (AllowOverride� �$¸é) .htaccessOptions � � Options All MultiViews� � � ' ÁÖ � ' �

MultiViews� �) � � � � � �4 �� /some/dir/foo 2 �� /some/dir/foo MultiViews� � /some/dir/foo� Á¸, ' °æ � ¸® � foo.* �� ¸ð � � � type map � ��48 � 2 media type� content-encoding �'� � � � �

MultiViews �� ¸® ÂüÁ¶ � ã DirectoryIndex � � �< � � °¶¸é,

DirectoryIndex index

index.html� index.html3 ¸ð ¤¸� � � $ � °á ¸ð � index.cgi� ¤¸�, � ±× �

¸® � � � Charset, Content-Type, Language, Encoding� � mod_mime ¸ð¸£ � � °Â©¸�, °á°ú MultiViewsMatch ' � �� � �� ¤¸� � � MultiViews Âü, ' � � °á

top

¹æ

9� type-map �4 ¸® �� ÁÖ4 � ¸ñ � � '5' � °á ±â ¹æ $ � �) 9 �) ±â� �) ±â �� �4 ' � ±×� �� � ¹æ �

�' ¹æ

  1. 9 ³¸� �) �� ÁÖ � °æ0 �) 9 ³¸� � � ³¸� �) � 9 °á°ú� »±� "" � � '�(quality factor)� 'Á¶ . 9� '�� Á¶ ¹æ � �
  2. �$� Transparent) �) �<0 � RFC 2295 ¹æ� 2 °æ0 � �) ¹æ '5' � °á � �<0 � ½¬ ±× °á°ú �<0 ³¸� �� �$� °ú $ �<0 9� RFC 2296 '� � ³¸� (remote variant selection algorithm)' 2

�

�
Media Type �<0 Accept � � � � � �� '�� �' � � '�� ("qs" � �'
Language �<0 Accept-Language � � � � � �� '�� �' � � �4 �' (� � �4 )
Encoding �<0 Accept-Encoding � � � � � �� '�� �'
Charset �<0 Accept-Charset � � � � � �� '�� �' � media type �� ¹® �

9 ³¸�

9 �<0 � º¸ '5' � (¤¸�) ±â ³¸� �) ³¸� ó°� � �

  1. ¸Õ , � � �� Accept* � � °ß �, � � '� ¸Å±ä � � Accept* � � ¹ã4 � º¸ � � � �<¸é 4 � � �
  2. º¸ � '5' � ã � � °ß � �4 � °ß ' � � � °ß �� �<¸é � 5 º¼ � 3 � � � � � �<¸é � °ß '
    1. Accept � '� � media type '� °ö � � �' �
    2. � � language) '�� �' �
    3. Accept-Language � (¤¸�) �4 � LanguagePriority � (¤¸�) �4 � �'� � � �4 �' �
    4. � (text/html media type � � ) 'level' media �� �' �
    5. Accept-Charset � � �'� � � charset media �� �' � ã � � ¤¸� ISO-8859-1 ¹® � � � text/* media type �''� º¼ � ¹® �°ú °°�' � ISO-8859-1� �
    6. ISO-8859-1 charset media �� �' ¼ä ±× � ¤¸�, ¸ð �
    7. � � �) �' � user-agent � �) �' � ¤¸� � �� ±× '� �) �� �) � � ¤¸� �) �� � ¸ð �) °Å ¸ð �) °æ ¸ð �
    8. content length� � �
    9. � �$ ù � � type-map � °Å , ¸® � � °æ � ASCII = � � ¬´
  3. � ³¸� '5' � � �< º¸� HTTP � Vary �� � (�<0 ļ ļ º¸ �) ) .
  4. � � ¤¸� (¸ð �<0 � �'¸ø � ¹® ) � � °æ0 ("No acceptable representation"� � ) 406� �)< �)� � ¸ñ � HTML ¹® � � º¸� , HTML Vary � � �� �
top

'� Á¶ �/a>

9 "" 9 ³¸� °Ý © � '�� ó°� � � º¸ º¸� �<0 � (³¸� ) °á°ú� º¸ô±� � � �4 �<0 $ � # ¸ø � � Accept � � º¸� �<0 � � � � º¸ º¸�ä¸�, Á¶ '

Media Type� � Ä«

Accept: 2 � media type � � , * � ¹®44� �% ±â ¹® "image/*" "*/*" � '� Ä« ' media type �) ±× � � � 2:

Accept: image/*, */*

"image/"� � type� ¤¸� � type �% � ¹Ì � �<0 � � ¤·� type 6�� � Ä« � º¸� � ¤¸�:

Accept: text/html, text/plain, image/gif, image/jpeg, */*

� ' ´°� type � '� ¤¸� ¤¸� ±× �0 ´±� � �<0 � � � � � � � º¼ '� �) ¬´

Accept: text/html, text/plain, image/gif, image/jpeg, */*; q=0.01

' ´°� type '�� � ±âº»� (� ) 1.0 �' � Ä« */* � 0.01 �'�� ' ´°� type � � °æ0 � ¤¸� type� �)

Accept: � q �� � "*/*"� ¤¸�, 9 �' q °¾ 0.01 ' , "type/*" � Ä« ("*/*"º¸� � �) 0.02� ' Accept: � q �� �' media type ¤¸� � � � 6�' /em>. ±× � º¸ º¸� �<0 2 ̰ 2¸®

� language) /a>

9 2.0 � � � °æ ½½ º¹±¸±â ³¸� � � �� 6�

��48 � � � � 2 �� �<0 � º¸ Accept-language � � � �� ã<¸é ¹® � '�, ±×� °æ � ��48 � � "No Acceptable Variant" "Multiple Choices" � º¸� � � ¹® � ±â °æ Accept-language� ¹« � ��48 � 2 � �' '� ¹® � º¸� � 9� � ForceLanguagePriority � �� � � ¹® � � ¹« � LanguagePriority � � �

, � � �4 ¸øÃ£ °æ ö¸�84 ã � � ��48 � ±¼ � en-GB �4 ¹® � 2 °æ HTTP/1.1 $ °¸�� � en� � ¹® � �� ' ¸ø (±× ±¼ � � � � � � � � � Accept-Languageen-GB� � � � en � � ²¸é °Å � ¸ø � � � ��48 �� � � ±âº»� ) ¤¸� �4 ã ¸ø �� "No Acceptable Variants" � � º¸ô°� LanguagePriority� � ¤¸�, � � � ¹« � en-GB� en ¹® ¹¬< 9 ö¸�84 ¸Å '°¾ ��48 � �8 ¸ñ 6� ±×� ��48 � "en-GB; q=0.9, fr; q=0.8" 2� � "en"� "fr" ¹® � ¤¸�, "fr" ¹® � � ÁÖ � HTTP/1.1 $ © , � � � ��48 � �(< ±â(4

�) � � �4 ´±� (Äï � URL-°æ �) �� ±â '±â 9 2.0.47� mod_negotiation prefer-language°æ � � °æ � Á¸, � �4 ±× � � ¤¸�, mod_negotiation �� � � ±× � ¤¸� � °ú

SetEnvIf Cookie "language=(.+)" prefer-language=$1

top

�$� transparent) �) /a>

9 � � � �$� �) �= (RFC 2295) � � ¸ñ � {encoding ..} � content-encoding �' �� '9 RVSA/1.0 ³¸� (RFC 2296) ¸ñ �) � � �, �) Accept-Encoding 2 � � °æ �) ¼ä º¸ �) � � RVSA/1.0 ±¸ 5 � ã±â °õ '�� 5¸® �,¸²'

top

� �� � �9 /a>

� language) �) ¤¸� � � � � �'� � º¸ ´°� � � � ¤¸� � �9 �) (� �) mod_mime ¹® � Âü )

� MIME-type � (� � /em>, html), °æ0 � encoding � (� � /em>, gz), � � � � °æ ¹° � � � (� � /em>, en) �'

:

� �� � � � � � � � ' � �� º¸8

� � � /th> � ' � � /th>
foo.html.en foo
foo.html
-
foo.en.html foo foo.html
foo.html.en.gz foo
foo.html
foo.gz
foo.html.gz
foo.en.html.gz foo foo.html
foo.html.gz
foo.gz
foo.gz.html.en foo
foo.gz
foo.gz.html
foo.html
foo.html.gz.en foo
foo.html
foo.html.gz
foo.gz

� º¸¸é � �� � � � (� � /em>, foo) �) °æ � ¹® � "�� ¨±� � , � � /em> �� ÂüÁ¶� � htmlshtmlcgi� ó°� � �

� � �� MIME-type (� � /em>, foo.html) �) � �ä¸� (encoding � � ¤¸� � � � � � � MIME-type � º¸ ¤¸¥Â� (� � /em>, foo.html.en) �<

top

ļ /a>

ļ � � � 2 URL �� � � � URL 2� ļ � �) ±×� � �% °æ ù ' 2 �� ļ � 2 ļ ¸ø � � � ç±� 9 º¸ �) � ¸ð 2 HTTP/1.0 ��48 � ļ ¸ø � � , 9 � ļ � HTTP/1.1 �= ±â� '

CacheNegotiatedDocs � HTTP/1.0 � ��48 �<0 � :� º¸ 2 � ļ � � � °¼$ � �) � ·¸� � �' � HTTP/1.1 ��48 � ̳� ���

HTTP/1.1 ��48 � � 9 � �� ¤Á� Vary HTTP � � � º¸� º¸ �) � 2 ļ º¹,º»� ü ' � � �� ļ º¹,º» ±Ë¸é force-no-vary °æ � �

�% �  en� |  fr� |  ja� |  ko� |  tr�

top

Comments

Notice:
This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our mailing lists.