Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between HTTP_URL, REQUEST_URI and these other IIS variables?

I came across various <rewrite> rules and noticed there are a lot of variables that appear to be the same. The IIS Server Variables documentation isn't really helping, for example it doesn't explain any difference between PATH_INFO and URL, it doesn't even mention REQUEST_URI at all, etc.

{HTTP_URL}      = /path/to/file.ext?key=value
{PATH_INFO}     = /path/to/file.ext
{R:1}           = /path/to/file.ext
{REQUEST_URI}   = /path/to/file.ext?key=value
{UNENCODED_URL} = /path/to/file.ext?key=value
{URL}           = /path/to/file.ext
{URL_PATH_INFO} = /path/to/file.ext

Besides the query string, I haven't found any other differences so far. Are there other differences, and why do we have multiple variables with the same value?

like image 903
Rudey Avatar asked Jan 03 '18 11:01

Rudey


People also ask

What is Request_uri in URL Rewrite?

Returns exact URL what you requested. For example, if you have default.aspx file in the root and you will access your website root.

What is Request_uri?

REQUEST_URI is the path component of the URI in the request. For example, /tq_info. php . REQUEST_FILENAME is the result of trying to find the file in the local filesystem by applying the URI path to the document root or any alias that might have been defined.

What is the difference between URL Rewrite and redirect?

Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.

What are server variables IIS?

IIS Server Variables provide information about the server, the connection with the client, and the current request on the connection. Additionally, inbound URL rewrite rules can be used to set custom server variables. Not all server variables listed in this document are available in versions of IIS prior to IIS 8.5.


1 Answers

I cannot answer completely to your question (because documentation is not clear) and I did some research about that. Here are my findings for some variables:

{REQUEST_URI}

Returns exact URL what you requested. For example, if you have default.aspx file in the root and you will access your website root. Then:

{REQUEST_URI} is ""

{PATH_INFO}, {HTTP_URL}, {UNENCODED_URL} is "/default.aspx"

{R:1}

Returns a first match in your regexp. For example, if you match regexp is part(.*)part(.*)part(.*) and you will access url /partApartBpartC. Then:

{R:0} is "partApartBpartC"

{R:1} is "A"

{R:2} is "B"

{R:3} is "C"

{UNENCODED_URL}

Returns the raw, unencoded URL. For example if you will access /"asdasd"""""asdsa Then:

{REQUEST_URI} is /"asdasd"""""asdsa

{UNENCODED_URL} is /%22asdasd%22%22%22%22%22asdsa

like image 169
Victor Leontyev Avatar answered Oct 22 '22 22:10

Victor Leontyev