2011-06-13 4 views
0

그래서 내가왜 내 IIS 7 다시 쓰기 규칙이 작동하지 않습니까?

 <rule name="rewrite /blog/"> 
      <match url="^/blog/([_0-9a-z-]+)/" /> 
      <conditions>     
      </conditions> 
      <action type="Rewrite" url="/{R:1}/" /> 
     </rule> 

은 그래서 Web.config의 지금이 들어 워드 프레스의 Web.config에 추가 http://mydomain.com/blog/blahblah/

http://mydomain.com/blahblah/에 리디렉션 할 필요가 IIS 7에서 3 WP 리눅스에서 워드 프레스 뮤 블로그를 마이그레이션 한 :

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
       <rule name="wordpress" patternSyntax="Wildcard"> 
        <match url="*" /> 
         <conditions> 
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
         </conditions> 
        <action type="Rewrite" url="index.php" /> 
       </rule> 
     <rule name="rewrite /blog/"> 
      <match url="^/blog/([_0-9a-z-]+)/" /> 
      <conditions>     
      </conditions> 
      <action type="Rewrite" url="/{R:1}/" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

Wordpress는 계속 작동하지만/blog /는 리디렉션되지 않습니다. 왜 ?

답변

3

1) 더 나은 이동 와일드 카드 규칙

2) 당신은 슬래시 ^/blog/...을 선도했던 이상이 규칙 - 당신은 그것을 필요가 없습니다 : 어떤 조건을 사용하지 않았기 때문에 ^blog/...

3) 나는 또한 <conditions></conditions>

을 제거한
<rule name="rewrite /blog/"> 
    <match url="^blog/([_0-9a-zA-Z\-]+)/$"/> 
    <action type="Rewrite" url="/{R:1}/"/> 
</rule> 

위입니다 규칙을 다시 작성 - 당신이 브라우저에서 동일한 URL을 볼 수 있지만 그것을 다르게 실행 뒤에.

당신이 리디렉션이 다음 아래 사용하려면 다음

<rule name="rewrite /blog/"> 
    <match url="^blog/([_0-9a-zA-Z\-]+)/$"/> 
    <action type="Redirect" url="/{R:1}/" redirectType="Permanent" /> 
</rule> 
+0

내가 복사의 Web.config에 붙여하지만 여전히 발생하지 않습니다 리디렉션 : 오류 404 – user310291

+0

내 대답을 업데이트 한 - – LazyOne

+0

을 확인하시기 바랍니다 아아아 덕택에 감사합니다. 차이점을 알지 못했지만 지금은 작동합니다. :) – user310291

관련 문제