home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 May / Gamestar_62_2004-05_dvd.iso / Programy / apache_2.0.48-win32-x86-no_ssl.msi / Data.Cab / F252067_cgi_path.html.en < prev    next >
Extensible Markup Language  |  2003-06-29  |  7KB  |  115 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
  4.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  5.               This file is generated from xml source: DO NOT EDIT
  6.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  7.       -->
  8. <title>PATH_INFO Changes in the CGI Environment - Apache HTTP Server</title>
  9. <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
  10. <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
  11. <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
  12. <link href="./images/favicon.ico" rel="shortcut icon" /></head>
  13. <body id="manual-page"><div id="page-header">
  14. <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
  15. <p class="apache">Apache HTTP Server Version 2.0</p>
  16. <img alt="" src="./images/feather.gif" /></div>
  17. <div class="up"><a href="./"><img title="<-" alt="<-" src="./images/left.gif" /></a></div>
  18. <div id="path">
  19. <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="./">Version 2.0</a></div><div id="page-content"><div id="preamble"><h1>PATH_INFO Changes in the CGI Environment</h1>
  20. <div class="toplang">
  21. <p><span>Available Languages: </span><a href="./en/cgi_path.html" title="English"> en </a> |
  22. <a href="./ja/cgi_path.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  23. <a href="./ko/cgi_path.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  24. </div>
  25.  
  26.     <p>As implemented in Apache 1.1.1 and earlier versions, the
  27.     method Apache used to create PATH_INFO in the CGI environment
  28.     was counterintuitive, and could result in crashes in certain
  29.     cases. In Apache 1.2 and beyond, this behavior has changed.
  30.     Although this results in some compatibility problems with
  31.     certain legacy CGI applications, the Apache 1.2 behavior is
  32.     still compatible with the CGI/1.1 specification, and CGI
  33.     scripts can be easily modified (<a href="#compat">see
  34.     below</a>).</p>
  35.   </div>
  36. <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#prob">The Problem</a></li>
  37. <li><img alt="" src="./images/down.gif" /> <a href="#solution">The Solution</a></li>
  38. <li><img alt="" src="./images/down.gif" /> <a href="#compat">Compatibility with Previous Servers</a></li>
  39. </ul></div>
  40. <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  41. <div class="section">
  42. <h2><a name="prob" id="prob">The Problem</a></h2>
  43.     <p>Apache 1.1.1 and earlier implemented the PATH_INFO and
  44.     SCRIPT_NAME environment variables by looking at the filename,
  45.     not the URL. While this resulted in the correct values in many
  46.     cases, when the filesystem path was overloaded to contain path
  47.     information, it could result in errant behavior. For example,
  48.     if the following appeared in a config file:</p>
  49.  
  50.     <div class="example"><p><code>
  51.       Alias /cgi-ralph /usr/local/httpd/cgi-bin/user.cgi/ralph
  52.     </code></p></div>    
  53.  
  54.     <p>In this case, <code>user.cgi</code> is the CGI script, the
  55.     "/ralph" is information to be passed onto the CGI. If this
  56.     configuration was in place, and a request came for
  57.     "<code>/cgi-ralph/script/</code>", the code would set PATH_INFO
  58.     to "<code>/ralph/script</code>", and SCRIPT_NAME to
  59.     "<code>/cgi-</code>". Obviously, the latter is incorrect. In
  60.     certain cases, this could even cause the server to crash.</p>
  61.   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  62. <div class="section">
  63. <h2><a name="solution" id="solution">The Solution</a></h2>
  64.     <p>Apache 1.2 and later now determine SCRIPT_NAME and PATH_INFO
  65.     by looking directly at the URL, and determining how much of the
  66.     URL is client-modifiable, and setting PATH_INFO to it. To use
  67.     the above example, PATH_INFO would be set to
  68.     "<code>/script</code>", and SCRIPT_NAME to
  69.     "<code>/cgi-ralph</code>". This makes sense and results in no
  70.     server behavior problems. It also permits the script to be
  71.     guaranteed that
  72.     "<code>http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO</code>"
  73.     will always be an accessible URL that points to the current
  74.     script, something which was not necessarily true with previous
  75.     versions of Apache.</p>
  76.  
  77.     <p>However, the "<code>/ralph</code>" information from the
  78.     <code>Alias</code> directive is lost. This is unfortunate, but
  79.     we feel that using the filesystem to pass along this sort of
  80.     information is not a recommended method, and a script making
  81.     use of it "deserves" not to work. Apache 1.2b3 and later,
  82.     however, do provide <a href="#compat">a workaround.</a></p>
  83.   </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  84. <div class="section">
  85. <h2><a name="compat" id="compat">Compatibility with Previous Servers</a></h2>
  86.     
  87.  
  88.     <p>It may be necessary for a script that was designed for
  89.     earlier versions of Apache or other servers to need the
  90.     information that the old PATH_INFO variable provided. For this
  91.     purpose, Apache 1.2 (1.2b3 and later) sets an additional
  92.     variable, FILEPATH_INFO. This environment variable contains the
  93.     value that PATH_INFO would have had with Apache 1.1.1.</p>
  94.  
  95.     <p>A script that wishes to work with both Apache 1.2 and
  96.     earlier versions can simply test for the existence of
  97.     FILEPATH_INFO, and use it if available. Otherwise, it can use
  98.     PATH_INFO. For example, in Perl, one might use:</p>
  99.  
  100.     <div class="example"><p><code>
  101.       $path_info = $ENV{'FILEPATH_INFO'} || $ENV{'PATH_INFO'};
  102.     </code></p></div>
  103.  
  104.     <p>By doing this, a script can work with all servers supporting
  105.     the CGI/1.1 specification, including all versions of
  106.     Apache.</p>
  107.   </div></div>
  108. <div class="bottomlang">
  109. <p><span>Available Languages: </span><a href="./en/cgi_path.html" title="English"> en </a> |
  110. <a href="./ja/cgi_path.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  111. <a href="./ko/cgi_path.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  112. </div><div id="footer">
  113. <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
  114. <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
  115. </body></html>