E
E
Eugene K.2016-07-25 12:01:19
URL Handling
Eugene K., 2016-07-25 12:01:19

Can anyone explain in plain language the essence of the operation of the [DPI] flag for RewriteRule?

I don’t understand what exactly the [DPI] flag in the RewriteRule does.
Yes, there is a description:

The DPI flag causes the PATH_INFO portion of the rewritten URI to be discarded.
This flag is available in version 2.2.12 and later.
In per-directory context, the URI each RewriteRule compares against is the concatenation of the current values ​​of the URI and PATH_INFO.
The current URI can be the initial URI as requested by the client, the result of a previous round of mod_rewrite processing, or the result of a prior rule in the current round of mod_rewrite processing.
In contrast, the PATH_INFO that is appended to the URI before each rule reflects only the value of PATH_INFO before this round of mod_rewrite processing.As a consequence, if larges of the URI are matched and copied into a substitution in multiple RewriteRule directives, without regard for which portions of the URI came from the current PATH_INFO, the final URI may have multiple copies of PATH_INFO appended to it.
Use this flag on any substitution where the PATH_INFO that resulted from the previous mapping of this request to the filesystem is not of interest. This flag permanently forgets the PATH_INFO established before this round of mod_rewrite processing began. PATH_INFO will not be recalculated until the current round of mod_rewrite processing completes. Subsequent rules during this round of processing will see only the direct result of substitutions, without any PATH_INFO appended.

Only not everything is clear, especially I can not translate into normal Russian in bold.
In which case PATH_INFO is added, and in which it is not.
And in general, what is PATH_INFO in the framework of .htaccess processing? For example. Let's say the path to the site root is /home/site/html, .htaccess is in the /first folder, and the user types the request /dir/second?hello.
And at the same time, one more question on the topic: why does RewriteRule (.*) $1 [R=301] (namely, when the second parameter without a slash at the beginning) adds /home/site/html to the site address when making a redirect (and only if when RewriteBase is not set and only when [R] is specified)? In other cases (with a slash, without R) nothing is added...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question