How to check a request is subrequest or not?

How can I check a request is subrequest or not at the config files?

Posted at Nginx Forum:

Is these any variable just like the IS_SUBREQ Flag in apache?

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

IS_SUBREQ
Will contain the text “true” if the request currently being
processed is a sub-request, “false” otherwise. Sub-requests may be
generated by modules that need to resolve additional files or URIs in
order to complete their tasks.

Posted at Nginx Forum:

Hi,

How can I check a request is subrequest or not at the config files?

if (r != r->main) {
/* this is subrequest */
}

Best regards,
Piotr S. < [email protected] >

Hi Piotr,

I want to define a request in nginx config file, such as,
/etc/nginx/nginx.conf.

For example:

server {

if($IS_SUBREQ){
do something
}

}

Posted at Nginx Forum:

Hi,

I want to define a request in nginx config file, such as,
/etc/nginx/nginx.conf.

Ah, sorry. I’ve missed the “at the config files” part.

I don’t think this is possible with nginx.conf.

Best regards,
Piotr S. < [email protected] >

As there are two variables in http core module:

$request_uri
This variable is equal to the original request URI as received from
the client including the args. It cannot be modified. Look at $uri for
the post-rewrite/altered URI.

$uri
This variable is equal to current URI in the request (without arguments,
those are in $args.) It can differ from $request_uri which is what is
sent by the browser. Examples of how it can be modified are internal
redirects, or with the use of index.

They are different at subrequest or internal redirects, but it is
impossible to define is subrequest or not at server{} part ?

Can I compare some variables to do so?

Posted at Nginx Forum: