IIS URL & Request Related Variables

 Sure! These variables are typically found in web server environments like Apache or IIS and are used by server-side applications (like PHP, Python, ASP.NET, etc.) to understand request data, file paths, and configuration settings.

Below is an explanation of each with examples where applicable.


✅ URL & Request Related Variables


1. CACHE_URL

  • Description: IIS-specific; relates to cached URLs in output caching.

  • Example: /cached-page.html

  • Use: Used internally by IIS for cached content lookup.


2. DOCUMENT_ROOT

  • Description: The absolute path to the root directory for the web server (where web content is served from).

  • Example:
    C:/inetpub/wwwroot (Windows IIS)
    /var/www/html (Apache/Linux)


3. HTTP_URL

  • Description: Often a custom environment variable; not always standard. Could represent the full HTTP URL.

  • Example: http://example.com/index.php?user=123


4. HTTP_HOST

  • Description: Host header sent by the client.

  • Example: www.example.com


5. PATH_INFO

  • Description: Extra path information provided after the script name in the URL.

  • Example: If URL is /index.php/user/123, and script is index.php, then:
    PATH_INFO = /user/123


6. PATH_TRANSLATED

  • Description: Filesystem path equivalent to PATH_INFO.

  • Example:
    C:/inetpub/wwwroot/user/123


7. QUERY_STRING

  • Description: The query string part of the URL after the ?.

  • Example:
    For /index.php?id=10&name=John,
    QUERY_STRING = id=10&name=John


8. REQUEST_FILENAME

  • Description: The absolute file path to the script being executed.

  • Example:
    /var/www/html/index.php


9. REQUEST_URI

  • Description: The full URI as requested by the client, including path and query string.

  • Example:
    /index.php?user=123


10. SCRIPT_FILENAME

  • Description: The absolute path to the script being executed (like index.php).

  • Example:
    C:/inetpub/wwwroot/index.php


11. SCRIPT_NAME

  • Description: The relative path to the script from the root of the website.

  • Example:
    /index.php


12. SCRIPT_TRANSLATED

  • Description: IIS-specific variable; maps the requested URI to a physical path.

  • Example:
    If URL is /foo/bar,
    SCRIPT_TRANSLATED = C:\inetpub\wwwroot\foo\bar


13. UNENCODED_URL

  • Description: IIS variable; shows the original URL before encoding.

  • Example:
    /path with space/file.html (not URL-encoded)


14. URL

  • Description: IIS variable; the URL portion of the request.

  • Example:
    /index.php


15. URL_PATH_INFO

  • Description: IIS variable; similar to PATH_INFO, often used in ISAPI applications.

  • Example:
    /extra/path/data



✅ IIS or Application Pool Related Variables


16. APP_POOL_ID

  • Description: Name of the IIS Application Pool that is processing the request.

  • Example:
    DefaultAppPool


17. APPL_MD_PATH

  • Description: The IIS metabase path for the application.

  • Example:
    /LM/W3SVC/1/ROOT


18. APPL_PHYSICAL_PATH

  • Description: Physical file system path to the application root.

  • Example:
    C:\inetpub\wwwroot\myapp\


19. GATEWAY_INTERFACE

  • Description: The version of the Common Gateway Interface (CGI) used.

  • Example:
    CGI/1.1


20. SERVER_SOFTWARE

  • Description: The name and version of the server software.

  • Example:
    Microsoft-IIS/10.0
    or
    Apache/2.4.41 (Unix)


21. SSI_EXEC_DISABLED

  • Description: IIS-specific; indicates that execution of commands via Server Side Includes (SSI) is disabled.

  • Example:
    true or false


✅ Summary Table

VariableDescriptionExample
CACHE_URLCached URL used by IIS/page.html
DOCUMENT_ROOTWeb root pathC:/inetpub/wwwroot
HTTP_URLFull URL (not standard)http://example.com/path
HTTP_HOSTDomain name from Host headerexample.com
PATH_INFOExtra path after script/user/123
PATH_TRANSLATEDFilesystem path from PATH_INFOC:/.../user/123
QUERY_STRINGURL query stringid=5&name=test
REQUEST_FILENAMEFull file path to requested file/var/www/index.php
REQUEST_URIEntire URI sent by client/index.php?x=1
SCRIPT_FILENAMEFull file path of the scriptC:/.../index.php
SCRIPT_NAMERelative path to the script/index.php
SCRIPT_TRANSLATEDMapped physical path of script (IIS)C:/.../foo/bar
UNENCODED_URLOriginal URL before encoding (IIS)/path with space/
URLURL part of the request (IIS)/index.php
URL_PATH_INFOExtra path info (IIS)/info/here
APP_POOL_IDName of the app pool (IIS)DefaultAppPool
APPL_MD_PATHIIS metabase path/LM/W3SVC/1/ROOT
APPL_PHYSICAL_PATHPhysical path to applicationC:/inetpub/...
GATEWAY_INTERFACECGI versionCGI/1.1
SERVER_SOFTWAREWeb server name/versionIIS/10.0
SSI_EXEC_DISABLEDWhether SSI execution is disabled (IIS)true

No comments:

Post a Comment

starter ASP.NET Core Web API project with example

Starter ASP.NET Core Web API project that follows all the best practices listed above. 🛠️ Starter Project Overview We’ll build a Produc...

Best for you