IIS Redirect - Перенаправление на новый сайт, кроме указанной страницы - PullRequest
0 голосов
/ 31 марта 2020

На моем сайте я должен написать правило перенаправления IIS и условия

Если URL-адрес страницы содержит ". Jp / en / anypage" или ". Jp / JP / anypage ", затем перенаправить на новый сайт, за исключением того, что URL содержит" jp / slide / evenity"или" jp / slide / xyz", затем остаться на том же сайте.

Я пишу ниже три правила, но правило № 3 блокирует правило 1 и 2: - предложить подход

<rule name="www-mysite-co-jp - Redirect 1">
                             <match url="^jp/slide/evenity/login\/$" />  
                             <conditions>
                               <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                             </conditions>
                             <action type="Redirect" url="https://preview.mysite.co.jp/slide/evenity/login/" appendQueryString="false" redirectType="Permanent" logRewrittenUrl="true" />
                </rule> 
                <rule name="www-mysite-co-jp - Redirect 2">
                             <match url="^jp/slide/xyz/login\/$" />  
                             <conditions>
                               <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                             </conditions>
                             <action type="Redirect" url="https://preview.mysite.co.jp/slide/xyz/login/" appendQueryString="false" redirectType="Permanent" logRewrittenUrl="true" />
                </rule> 

                <rule name="www-mysite-co-jp - Redirect 3">
                             <match url="^(jp|en)/(.*)$" />  
                             <conditions>
                               <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                             </conditions>
                             <action type="Redirect" url="https://preview.new.co.jp/" appendQueryString="false" redirectType="Permanent" logRewrittenUrl="true" />
                </rule> 

1 Ответ

0 голосов
/ 01 апреля 2020

Если вы хотите переписать

preview.mysite.co.jp/(en|jp)/anypage to https://preview.new.co.jp/ and rewrite

 preview.mysite.co.jp/jp/slide/(evenity|xyz)(.*)------>https://preview.mysite.co.jp/slide/(evenity|xyz)(.*)

Пожалуйста, попробуйте это. Для правила № 3

<rule name="www-mysite-co-jp - Redirect 1" stopProcessing="true">
                             <match url="^jp/slide/evenity(.*)$" />  
                             <conditions>
                        <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                             </conditions>
                             <action type="Redirect" url="https://preview.mysite.co.jp/slide/evenity{R:1}" appendQueryString="false" logRewrittenUrl="true" redirectType="Permanent" />
                </rule> 
                <rule name="www-mysite-co-jp - Redirect 2" stopProcessing="true">
                             <match url="^jp/slide/xyz(.*)$" />  
                             <conditions>
                        <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                             </conditions>
                             <action type="Redirect" url="https://preview.mysite.co.jp/slide/xyz{R:1}" appendQueryString="false" logRewrittenUrl="true" redirectType="Permanent" />
                </rule> 

                <rule name="www-mysite-co-jp - Redirect 3" stopProcessing="true">
                             <match url="^(jp|en)/(.*)$" />  
                             <conditions trackAllCaptures="true">
                        <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                        <add input="{URL}" pattern="^/jp/slide/(evenity|xyz)(.*)" negate="true" />
                             </conditions>
                             <action type="Redirect" url="https://preview.new.co.jp/" appendQueryString="false" redirectType="Permanent" logRewrittenUrl="true" />
                </rule> 

вам нужно добавить в белый список четность и xyz. Конечно, правила № 1 и № 2 можно смешивать.

 <rule name="www-mysite-co-jp - Redirect 1" stopProcessing="true">
                             <match url="^jp/slide/(evenity|xyz)(.*)$" />  
                             <conditions>
                        <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                             </conditions>
                             <action type="Redirect" url="http://preview.mysite.co.jp/slide/{R:1}{R:2}" appendQueryString="false" logRewrittenUrl="true" redirectType="Permanent" />
                </rule> 

                <rule name="www-mysite-co-jp - Redirect 3" stopProcessing="true">
                             <match url="^(jp|en)/(.*)$" />  
                             <conditions trackAllCaptures="true">
                        <add input="{HTTP_HOST}" pattern="^.*\.?preview.mysite.co\.jp$" />
                        <add input="{URL}" pattern="^/jp/slide/(evenity|xyz)(.*)" negate="true" />
                             </conditions>
                             <action type="Redirect" url="http://preview.new.co.jp/" appendQueryString="false" logRewrittenUrl="true" redirectType="Permanent" />
                </rule> 
...