2011-08-10 3 views
1

아파치.htaccess를 IIS 용 web.config로 변환하십시오.

RewriteEngine On 
RewriteBase /folder 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule index.php.* - [L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*) index.php?id=$1 

에서 잘 작동하는 .htaccess에 대한 다음 코드가 있습니다. 그러나 IIS가있는 서버에서 실행해야합니다. IIS 용으로 번역 할 수 있도록 도와 주시겠습니까? 고마워.

답변

1

IIS 7을 사용하는 경우 Microsoft에서 제공 한 IIS 용 URL 다시 쓰기 확장을 설치할 수 있습니다. 이 확장 기능은 .htaccess 파일을 가져 오는 기능도 있습니다. 때로는 모든 라인을 다룰 수있는 것은 아닙니다 (아래 두 번째 줄을보십시오). 우리는 약간의 조정을해야합니다. 가져 오기 대화 상자의 'XML보기'탭의 결과를 텍스트 편집기에 복사하여 붙여넣고 'web.config'파일로 저장합니다. .htaccess가 다음과 같이 변환되었습니다.

<rewrite> 
    <!--This directive was not converted because it is not supported by IIS: RewriteBase /folder.--> 
    <rules> 
    <rule name="Imported Rule 1" stopProcessing="true"> 
     <match url="index.php.*" ignoreCase="false" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
     </conditions> 
     <action type="None" /> 
    </rule> 
    <rule name="Imported Rule 2"> 
     <match url="^(.*)" ignoreCase="false" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="index.php?id={R:1}" appendQueryString="false" /> 
    </rule> 
    </rules> 
</rewrite> 

참고 : 직접 가져 오기 결과가 아직 조정되지 않았습니다.

관련 문제