2013-09-25 4 views
1

이것은 아마도 간단한 질문이지만 URL 재 작성 규칙에서 파일을 제외하고 싶습니다. 아래 코드는 내 web.config 파일의 재 작성 섹션입니다 (이 코드는 다른 사람이 제공 한 것입니다). demo-download.php라는 파일을 확장자가 제거 된 것으로부터 제외하고 싶습니다. (그것은 내가 $ _POST를 사용하는 PHP 코드에서 문제를 일으킨다.)URL 다시 쓰기 특정 URL 제외

<rewrite> 
    <rules> 
    <rule name="extensionless" stopProcessing="true"> 
     <match url="(.*)\.php$" /> 
     <action type="Redirect" url="{R:1}" redirectType="Permanent" /> 
    </rule> 
    <rule name="removeextension" enabled="true"> 
     <match url=".*" negate="false" /> 
     <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      <add input="{URL}" pattern="(.*)\.(.*)" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="{R:0}.php" /> 
    </rule> 
    </rules> 
</rewrite> 

답변

0

당신이 줄을 추가 할 수 있습니다 : 두 규칙을 변경해야합니다

<add input="{REQUEST_FILENAME}" pattern=".*demo\-download\.php" negate="false" /> 
0

합니다.
그것은 다음과 같이 갈 것이다 :

<rewrite> 
    <rules> 
    <rule name="extensionless" stopProcessing="true"> 
     <match url="^demo-download" negate="true" /> 
     <conditions logicalGrouping="MatchAny"> 
      <add input="{REQUEST_FILENAME}" pattern="\.php$" /> 
     </conditions> 
     <action type="Redirect" url="{R:1}" redirectType="Permanent" /> 
    </rule> 
    <rule name="removeextension" enabled="true"> 
     <match url="^demo-download.php$" negate="true" /> 
     <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      <add input="{URL}" pattern="(.*)\.(.*)" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="{R:0}.php" /> 
    </rule> 
    </rules> 
</rewrite> 

요청 된 파일 이름이 demo-download으로 시작하고 .php 확장자가없는 경우 첫 번째 규칙 만 적용됩니다. 두 번째 방법은 요청 된 경로가 정확히 일치하지 않는 경우에만 적용됩니다. demo-download.php