2013-01-09 2 views
0

PHP 7 사이트에 URL 재 작성 모듈을 배포했지만 재 작성 규칙이 작동하지 않습니다. 다음은 내 실제 URL 및 URL 내가 브라우저에 표시 할 수 있습니다URL 다시 쓰기가 IIS 7에서 작동하지 않습니다.

브라우저 URL : 이전에 나는 아래 WAMP 서버와에 따라 .htaccess 모드 재 작성을 사용했다 http://mydomain.com/myfolder/myfile.html

: http://mydomain.com/myfolder 또는

실제 URL http://mydomain.com/myfolder/anytext htaccess로 파일에 정의 된 작업 규칙이

다음
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteCond %{REQUEST_URI} ^(.+)/$ 

RewriteRule ^(.+)/$ /$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^.*$ myfile.html [L] 

제안하고 내 문제를 해결하기 위해 도와주세요, 작동하지 않는 내 web.config 파일입니다

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="Rewrite to myfile.html1"> 
       <match url="^(.+)/$" /> 
       <action type="Rewrite" url="/$1" /> 
      </rule> 
     </rules> 
     <rules> 
      <rule name="Rewrite to myfile.html2"> 
       <match url="^.*$" /> 
       <action type="Rewrite" url="myfile.html" /> 
      </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

답변

1

을이 Web.config의 날

<?xml version="1.0" encoding="UTF-8"?> 
    <configuration> 
     <system.webServer> 
     <directoryBrowse enabled="true" /> 
     <rewrite> 
      <rules> 
       <rule name="Rule1" stopProcessing="true"> 
        <match url="^(.+)/$" /> 
        <conditions> 
        <add input="{URI}" pattern="^(.+)/$" /> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
        </conditions> 
        <action type="Rewrite" url="/$1" /> 
       </rule> 
       <rule name="Rule2" stopProcessing="true"> 
        <match url="^myfolder/.*$" /> 
        <conditions> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
        </conditions> 
       <action type="Rewrite" url="myfolder/myfile.html" /> 
       </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
    </configuration> 
1

.htaccess 규칙은 실제로 서로 다른 두 가지 작업을 수행합니다. 우선 / (슬래시)으로 끝나는 요청이 슬래시가없는 URL로 리디렉션되는지 확인합니다. 두 번째 규칙은 존재하지 않는 파일에 대한 모든 요청을 myfile.html으로 다시 작성합니다. 일부 히트 후

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="Removing trailing slash" stopProcessing="true"> 
       <match url="^(.+)/$" /> 
       <conditions> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
       </conditions> 
       <action type="Redirect" url="/{R:1}" /> 
      </rule> 
     </rules> 
     <rules> 
      <rule name="Rewrite to myfile.html" stopProcessing="true"> 
       <match url="^.*$" /> 
       <conditions> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
       </conditions> 
       <action type="Rewrite" url="/myfile.html" /> 
      </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 
+0

이 웹 설정은 500.19 내부 ​​서버 오류가 표시되어 근무 시도 :

이 (안된) 작동합니다. 두 개의 규칙 태그가 정의 되었기 때문일 수 있습니다. 과거에도이 오류가 발생했습니다. –

+0

두 개의 ''태그는 하나의 ''섹션 아래에 결합되어야 작동합니다. –

관련 문제