@jin_x
Предприниматель, программист, вокалист

Кто-нибудь может объяснить понятным языком суть работы флага [DPI] для RewriteRule?

Никак не пойму, что именно делает флаг [DPI] в RewriteRule.
Да, есть описание:
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 large portions of the URI are matched and copied into a substitution in multiple RewriteRule directives, without regard for which parts 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.

Только не всё понятно, особенно не могу перевести на нормальный русский выделенное жирным шрифтом.
В каком случае добавляется PATH_INFO, а в каком – нет.

Да и вообще, что есть PATH_INFO в рамках обработки .htaccess? На примере. Допустим, путь к корню сайта /home/site/html, .htaccess лежит в папке /first, а юзер набирает запрос /dir/second?hello.

И заодно ещё один вопрос в тему: почему RewriteRule (.*) $1 [R=301] (именно когда второй параметр без слэша в начале) добавляет /home/site/html к адресу сайта при совершении редиректа (причём только в том случае, когда RewriteBase не задан и только при указании [R])? В остальных же случаях (со слэшем, без R) ничего не добавляется...
  • Вопрос задан
  • 248 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы