2017-12-13 19 views
0

https://example.com/xml으로 리디렉션되는 IIS에서 다시 쓰기 규칙을 작성해야합니다. 다시 쓸 URL에 대한 정규식

그래서
사례 1 : https://example.com/test
케이스 2 : https://example.com/[country-lang-token]/test

(예 https://example.com/en-us/testhttps://example.com/fr-fr/test)

https://example.com/xml로 리디렉션한다.

나는 규칙을 다시 작성하는 방법을 알고 있지만 정규 표현식으로 인해 붙어 있습니다.

답변

1

규칙은 다음과 같이해야합니다 :

<rule name="Redirect to xml" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAny"> 
     <add input="{REQUEST_URI}" pattern="^/test$" /> 
     <add input="{REQUEST_URI}" pattern="^/\w{2}-\w{2}/test$" /> 
    </conditions> 
    <action type="Redirect" url="/xml" /> 
</rule> 

첫 번째 조건은 경우 1 URL입니다 https://example.com/test 두 번째 조건은 [country-lang-token]이 형식의 문자열 인 경우 2 https://example.com/[country-lang-token]/test입니다 {two_letters}-{two_letters}