IIS переписывает URL дважды?

#php #iis #url-rewriting #url-rewrite-module

#php #iis #url-перезапись #url-rewrite-module

Вопрос:

У меня есть url ‘/quote/details/e4dd5f4e4c705436ba381b0dc06fccc0’, который перезаписывается в: ‘/quote/details/?retrieveQuote=e4dd5f4e4c705436ba381b0dc06fccc0’

 <rule name="Rewrite Saved Quote to Query String Type" stopProcessing="false">
    <match url="^quote/details/([^/] )/?$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="quote/details/?retrieveQuote={R:1}" appendQueryString="true" />
</rule>
 

Это работает, потому что, когда я устанавливаю stopProcessing в true, я получаю 404 с правильным выводом:
Запрошенная цитата URL / подробности /?retrieveQuote=e4dd5f4e4c705436ba381b0dc06fccc0

Теперь это должно быть переписано, как и остальная часть сайта, используя это:

 <rule name="Rewrite to Index" patternSyntax="Wildcard" stopProcessing="true">
    <match url="*" />
    <conditions>
        <add input="{URL}" pattern="/admin/ " ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="/api/ " ignoreCase="false" negate="true" />
        <add matchType="IsFile" negate="true" />
        <add matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
 

Но по какой-то причине этого не происходит, и если я использую $_SERVER[‘REQUEST_URI’], он выводит: quote/details/e4dd5f4e4c705436ba381b0dc06fccc0 но должно быть: quote/details/?retrieveQuote=e4dd5f4e4c705436ba381b0dc06fccc0

Есть идеи, как заставить его работать правильно?

Ответ №1:

Я не смог найти никакого решения этой проблемы, поэтому я создал правило маршрутизации и выделил требуемый параметр из URL.