2017-12-07 31 views
0

이미 밑줄이있는 경우 URL에 후행 밑줄을 추가하기 위해 URLRewrite를 작성하려고합니다. 이 PDF 파일URL에 후행 밑줄을 추가하는 URLRewrite 규칙

을 위해 특별히입니다

들어오는 URL : URL에 https://localhost/pdf/mypdf_.pdf 재 작성 : 들어오는 URL 밑줄이없는 경우 https://localhost/pdf/mypdf__.pdf

, 다음 규칙이 실행되지 않아야한다.

  <rule name="Init PDF Rules"> 
       <match url="(.*)" /> 
       <conditions> 
        <add input="{REQUEST_URI}" pattern="^.*_.pdf.*$" /> 
       </conditions> 
       <action type="Redirect" url="{C:1}_{C:2}" /> 
      </rule> 

는 좀 스택 교환 질문을 통해가는 시도했지만 완벽한 규칙을 쓸 수 없습니다.

답변

0

다음 규칙은 으로 끝나는 이름이 기존 파일이 아니고 밑줄에만 적용됩니다.

<rule name="rewrite pdf file names ending with a _"> 
    <match url="^(.*/)?(.*?)([^_]_)(\.pdf)$" /> 
    <conditions logicalGrouping="MatchAll"> 
     <!-- skip rewriting if the path is a directory or an existig file --> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="{R:1}{R:2}{R:3}_{R:4}" /> 
</rule>